fix(js-sdk): normalize pollInterval to prevent silent 83-min hang (ms/s double-conversion) by mad1081 · Pull Request #3382 · firecrawl/firecrawl · GitHub
Skip to content

fix(js-sdk): normalize pollInterval to prevent silent 83-min hang (ms/s double-conversion)#3382

Open
mad1081 wants to merge 1 commit intofirecrawl:mainfrom
mad1081:fix/poll-interval-ms-sec-double-conversion
Open

fix(js-sdk): normalize pollInterval to prevent silent 83-min hang (ms/s double-conversion)#3382
mad1081 wants to merge 1 commit intofirecrawl:mainfrom
mad1081:fix/poll-interval-ms-sec-double-conversion

Conversation

@mad1081
Copy link
Copy Markdown

@mad1081 mad1081 commented Apr 16, 2026

Summary

Fixes #3373firecrawl crawl --wait (without --progress) silently hangs ~83 minutes per poll cycle because of a double ms/s conversion between the CLI and the SDK.

The CLI converts --poll-interval 55000 (ms) before passing to app.crawl(). The SDK's polling functions then multiply by 1000 again (they expect seconds), producing 5000 × 1000 = 5,000,000 ms ≈ 83 min per poll. The crawl completes server-side and credits are consumed, but the CLI never returns.

Fix

Add a normalization guard at the entry of every SDK polling function: if pollInterval >= 1000, treat it as milliseconds and divide by 1000 before use. No legitimate polling use case requires intervals of 1000+ seconds (16+ minutes), so the threshold has zero false positives for normal callers while silently correcting accidentally-large ms values.

Three functions patched:

  • waitForCrawlCompletionapps/js-sdk/firecrawl/src/v2/methods/crawl.ts
  • waitForBatchCompletionapps/js-sdk/firecrawl/src/v2/methods/batch.ts
  • monitorJobStatusapps/js-sdk/firecrawl/src/v1/index.ts

Relevant prior art & context

Test plan

  • firecrawl crawl <url> --limit 1 --wait --poll-interval 5 completes in seconds (not 83 min)
  • firecrawl crawl <url> --limit 1 --wait --poll-interval 5000 (ms accidentally passed) also completes correctly (normalized to 5s)
  • Existing SDK callers passing correct seconds values (e.g. pollInterval: 2) are unaffected
  • batchScrape with an ms-sized pollInterval also normalizes correctly

Summary by cubic

Prevent 83‑minute hangs by normalizing polling intervals in the JS SDK to handle ms vs s correctly. Fixes #3373 so firecrawl crawl --wait polls at the intended frequency and returns promptly.

  • Bug Fixes
    • Normalize pollInterval/checkInterval: if ≥ 1000, treat as milliseconds and divide by 1000 before sleeping.
    • Applied to waitForCrawlCompletion (v2), waitForBatchCompletion (v2), and monitorJobStatus (v1).
    • Seconds-based callers are unchanged; ms inputs like 5000 now behave as 5s.

Written for commit ffd1cce. Summary will update on new commits.

…s/s double-conversion

Fixes firecrawl#3373 — firecrawl crawl --wait (without --progress) hangs ~83 minutes
per poll because the CLI converts --poll-interval from seconds to milliseconds
before calling app.crawl(), while the SDK polling functions also multiply by
1000 (they expect seconds). With --poll-interval 5 this produces
5 x 1000 x 1000 = 5,000,000 ms = 83 min per cycle.

Add a normalization guard at the top of every polling function: if pollInterval
>= 1000 it was almost certainly passed in milliseconds and is divided by 1000
before use. No legitimate use case polls every 1000+ seconds so the threshold
has no false positives for normal callers.

Affected: waitForCrawlCompletion, waitForBatchCompletion, monitorJobStatus
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 3 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/js-sdk/firecrawl/src/v1/index.ts">

<violation number="1" location="apps/js-sdk/firecrawl/src/v1/index.ts:1515">
P2: Heuristic misclassifies valid large second-based intervals as milliseconds, silently collapsing them to the 2s minimum polling interval.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Heuristic misclassifies valid large second-based intervals as milliseconds, silently collapsing them to the 2s minimum polling interval.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/js-sdk/firecrawl/src/v1/index.ts, line 1515:

<comment>Heuristic misclassifies valid large second-based intervals as milliseconds, silently collapsing them to the 2s minimum polling interval.</comment>

<file context>
@@ -1510,6 +1510,9 @@ export default class FirecrawlApp {
           ) {
+            // Normalize: if checkInterval looks like milliseconds (>= 1000), convert to seconds.
+            // This prevents a silent 1000x hang when callers accidentally pass ms instead of s.
+            if (checkInterval >= 1000) checkInterval = checkInterval / 1000;
             checkInterval = Math.max(checkInterval, 2);
             await new Promise((resolve) =>
</file context>
Fix with Cubic

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid point. In practice no polling use case requires ≥1000s intervals — but happy to fix the root cause in the CLI instead if that's preferred.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

firecrawl crawl --wait (without --progress) silently hangs ~83 minutes per poll due to double ms/sec conversion

1 participant