UNPKG

apx-toolkit

Version:

Automatically discover APIs and generate complete integration packages: code in 12 languages, TypeScript types, test suites, SDK packages, API documentation, mock servers, performance reports, and contract tests. Saves 2-4 weeks of work in seconds.

120 lines (86 loc) โ€ข 3.38 kB
# ๐Ÿ› Bug Fixes Applied **Date:** November 29, 2025 **Issue:** Test failure with invalid URLs and navigation errors --- ## ๐Ÿ” Issues Identified ### Issue 1: Failed Requests Crashed Actor **Problem:** When a URL failed to load (invalid domain, network error, etc.), the entire actor would crash instead of gracefully handling the error and continuing with other URLs. **Impact:** - Invalid URLs caused complete actor failure - Network errors stopped all processing - No partial success results --- ## โœ… Fixes Applied ### Fix 1: Added `failedRequestHandler` to PlaywrightCrawler **Location:** `src/main.ts` lines ~100-110 **Change:** - Added `failedRequestHandler` callback to gracefully handle failed requests - Logs warning instead of crashing - Allows other URLs to continue processing **Code:** ```typescript failedRequestHandler: async ({ request, error }) => { console.warn(`โš ๏ธ Failed to process request: ${request.url}`); console.warn(` Error: ${error instanceof Error ? error.message : String(error)}`); console.warn(` This URL will be skipped. Continuing with other URLs...`); // Don't throw - allow other URLs to continue processing } ``` --- ### Fix 2: Added `failedRequestHandler` to HttpCrawler **Location:** `src/main.ts` lines ~112-119 **Change:** - Added `failedRequestHandler` for API processing phase - Handles failed API requests gracefully - Continues processing other APIs --- ### Fix 3: Enhanced Error Messages in Discovery Handler **Location:** `src/handlers/discovery-handler.ts` lines ~437-460 **Changes:** - Added specific error detection for common issues: - Domain not found (ENOTFOUND) - Connection refused - SSL errors - Timeout errors - Provides helpful suggestions for each error type - Early return if navigation completely fails and no APIs discovered **Error Types Detected:** - `ERR_NAME_NOT_RESOLVED` / `ERR_NAME_RESOLUTION_FAILED` โ†’ Domain not found - `ERR_CONNECTION_REFUSED` โ†’ Server refused connection - `ERR_SSL` โ†’ SSL certificate issues - `timeout` / `Navigation timeout` โ†’ Page load timeout --- ### Fix 4: Wrapped Crawler Run in Try-Catch **Location:** `src/main.ts` lines ~144 **Change:** - Added catch handler for crawler.run() - Distinguishes between critical errors and individual request failures - Logs warnings but doesn't crash for non-critical errors --- ## ๐Ÿงช Testing ### Test Scenarios Now Handled: 1. โœ… **Invalid URLs** - Gracefully skipped with warning 2. โœ… **Non-existent domains** - Clear error message, continues 3. โœ… **Connection refused** - Detected and logged, continues 4. โœ… **SSL errors** - Detected and logged, continues 5. โœ… **Timeouts** - Handled gracefully, continues 6. โœ… **Multiple URLs with some failures** - Processes successful ones --- ## ๐Ÿ“Š Expected Behavior After Fixes ### Before: - โŒ Invalid URL โ†’ Actor crashes - โŒ Network error โ†’ Actor crashes - โŒ No partial results ### After: - โœ… Invalid URL โ†’ Warning logged, other URLs processed - โœ… Network error โ†’ Error logged with helpful message, continues - โœ… Partial results โ†’ Successful URLs processed, failed ones skipped --- ## ๐Ÿ”„ Next Steps 1. โœ… Build and test locally 2. โณ Push to GitHub 3. โณ Trigger new Apify build 4. โณ Re-run stress tests 5. โณ Verify all tests pass --- **Status:** โœ… Fixes applied, ready for testing