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
Markdown
# ๐ 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