FlowiseAI/Flowise · error · Error

Unexpected error occurred while trying to ${action}. Status

Error message

Unexpected error occurred while trying to ${action}. Status code: ${response.status}

What it means

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.

Source

Thrown at packages/components/nodes/documentloaders/FireCrawl/FireCrawl.ts:537

                        }
                        await new Promise((resolve) => setTimeout(resolve, Math.max(checkInterval, 2) * 1000))
                        break
                    default:
                        throw new Error(`Unknown extract status: ${statusData.status}`)
                }
            } else {
                this.handleError(statusResponse, 'check extract status')
            }
        }
        throw new Error('Failed to monitor extract status')
    }

    private handleError(response: AxiosResponse, action: string): void {
        if ([402, 408, 409, 500].includes(response.status)) {
            const errorMessage: string = response.data.error || 'Unknown error occurred'
            throw new Error(`Failed to ${action}. Status code: ${response.status}. Error: ${errorMessage}`)
        } else {
            throw new Error(`Unexpected error occurred while trying to ${action}. Status code: ${response.status}`)
        }
    }
}

// FireCrawl Loader
interface FirecrawlLoaderParameters {
    url?: string
    query?: string
    apiKey?: string
    apiUrl?: string
    mode?: 'crawl' | 'scrape' | 'extract' | 'search'
    params?: Record<string, unknown>
}

export class FireCrawlLoader extends BaseDocumentLoader {
    private apiKey: string
    private apiUrl: string
    private url?: string

View on GitHub (pinned to abe4a8601a)

Solutions

  1. 401/403: regenerate and re-store the API key.
  2. 429: add client-side throttling and exponential backoff; lower concurrency.
  3. 404: confirm apiUrl ends at the v1 root and the endpoint path exists.
  4. 5xx: retry with backoff; check FireCrawl status page.
  5. Patch handleError locally to also include `response.data?.error` for these statuses.

Example fix

// before (library)
throw new Error(`Unexpected error occurred while trying to ${action}. Status code: ${response.status}`)

// after
throw new Error(`Unexpected error during ${action}. Status ${response.status}. Body: ${JSON.stringify(response.data)}`)
Defensive patterns

Strategy: retry

Validate before calling

if (!apiKey) throw new Error('apiKey required')
try { new URL(apiUrl) } catch { throw new Error(`invalid apiUrl: ${apiUrl}`) }

Type guard

function isAuthOrRateStatus(status: number): boolean {
  return [401, 403, 429].includes(status)
}

Try / catch

for (let i = 0; i < 4; i++) {
  try { return await op() }
  catch (e) {
    const m = (e as Error).message
    if (/Status code: 401|Status code: 403/.test(m)) throw e // do not retry auth
    if (/Status code: 429|Status code: 5/.test(m)) { await sleep(1000 * 2 ** i); continue }
    throw e
  }
}

Prevention

When it happens

Trigger: 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).

Common situations: Expired API key (401); wrong apiUrl for self-hosted (404); burst traffic hitting rate limit (429); reverse-proxy returning 502.

Related errors


AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12). Data as JSON: /api/errors/edf978ac46f10908. Report an issue: GitHub.