{"record":{"id":"edf978ac46f10908","repo":"FlowiseAI/Flowise","slug":"unexpected-error-occurred-while-trying-to-action","errorCode":null,"errorMessage":"Unexpected error occurred while trying to ${action}. Status code: ${response.status}","messagePattern":"Unexpected error occurred while trying to (.+?)\\. Status code: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/documentloaders/FireCrawl/FireCrawl.ts","lineNumber":537,"sourceCode":"                        }\n                        await new Promise((resolve) => setTimeout(resolve, Math.max(checkInterval, 2) * 1000))\n                        break\n                    default:\n                        throw new Error(`Unknown extract status: ${statusData.status}`)\n                }\n            } else {\n                this.handleError(statusResponse, 'check extract status')\n            }\n        }\n        throw new Error('Failed to monitor extract status')\n    }\n\n    private handleError(response: AxiosResponse, action: string): void {\n        if ([402, 408, 409, 500].includes(response.status)) {\n            const errorMessage: string = response.data.error || 'Unknown error occurred'\n            throw new Error(`Failed to ${action}. Status code: ${response.status}. Error: ${errorMessage}`)\n        } else {\n            throw new Error(`Unexpected error occurred while trying to ${action}. Status code: ${response.status}`)\n        }\n    }\n}\n\n// FireCrawl Loader\ninterface FirecrawlLoaderParameters {\n    url?: string\n    query?: string\n    apiKey?: string\n    apiUrl?: string\n    mode?: 'crawl' | 'scrape' | 'extract' | 'search'\n    params?: Record<string, unknown>\n}\n\nexport class FireCrawlLoader extends BaseDocumentLoader {\n    private apiKey: string\n    private apiUrl: string\n    private url?: string","sourceCodeStart":519,"sourceCodeEnd":555,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/documentloaders/FireCrawl/FireCrawl.ts#L519-L555","documentation":"Thrown by handleError for any HTTP status NOT in {402,408,409,500}. Unlike the structured branch, this one does NOT read `response.data.error` — it only reports the status code, so the body's reason is lost.","triggerScenarios":"401 Unauthorized (bad/missing API key), 403 Forbidden (key lacks scope), 404 Not Found (wrong apiUrl or job id), 429 Too Many Requests (rate limit), 502/503/504 (gateway).","commonSituations":"Expired API key (401); wrong apiUrl for self-hosted (404); burst traffic hitting rate limit (429); reverse-proxy returning 502.","solutions":["401/403: regenerate and re-store the API key.","429: add client-side throttling and exponential backoff; lower concurrency.","404: confirm apiUrl ends at the v1 root and the endpoint path exists.","5xx: retry with backoff; check FireCrawl status page.","Patch handleError locally to also include `response.data?.error` for these statuses."],"exampleFix":"// before (library)\nthrow new Error(`Unexpected error occurred while trying to ${action}. Status code: ${response.status}`)\n\n// after\nthrow new Error(`Unexpected error during ${action}. Status ${response.status}. Body: ${JSON.stringify(response.data)}`)","handlingStrategy":"retry","validationCode":"if (!apiKey) throw new Error('apiKey required')\ntry { new URL(apiUrl) } catch { throw new Error(`invalid apiUrl: ${apiUrl}`) }","typeGuard":"function isAuthOrRateStatus(status: number): boolean {\n  return [401, 403, 429].includes(status)\n}","tryCatchPattern":"for (let i = 0; i < 4; i++) {\n  try { return await op() }\n  catch (e) {\n    const m = (e as Error).message\n    if (/Status code: 401|Status code: 403/.test(m)) throw e // do not retry auth\n    if (/Status code: 429|Status code: 5/.test(m)) { await sleep(1000 * 2 ** i); continue }\n    throw e\n  }\n}","preventionTips":["Patch handleError locally to log response.data for non-listed statuses — the body is otherwise lost.","Add client-side rate limiting (token bucket) to avoid 429.","Verify apiUrl resolves to the v1 root before deploying."],"tags":["firecrawl","http-status","auth","rate-limit","diagnostic-loss"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}