Skip to content

fix(crawl): wait out rate-limited status polls and page results only once the crawl ends - #570

Merged
capy-ai[bot] merged 2 commits into
mainfrom
capy/wait-out-rate-limited
Oct 19, 2026
Merged

capy-ai[bot] merged 2 commits into
mainfrom
capy/wait-out-rate-limited

Conversation

@erikengervall

@erikengervall erikengervall commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

firecrawl_crawl starts a crawl and then polls GET /v2/crawl/:id until it ends. Two things in that loop made the tool fail while the crawl itself was fine:

  • Each poll read every result page. getCrawlStatusWithOrigin follows next to collect all documents, and the loop called it on every tick, so a crawl with several result pages issued several status reads every couple of seconds and quickly used up the crawl-status rate limit.
  • A rate-limited poll failed the tool. The 429 surfaced as Request failed with status code 429, the crawl ID was lost, and the agent typically started the same crawl again.

Now the loop reads only the first status page while the crawl runs and collects result pages once, after it reaches completed, failed or cancelled. A 429 on a status read waits for Retry-After (or retry_after_seconds, default 10s, capped at 60s) and keeps polling; other errors still fail as before.

Test: tests/mcp-crawl-polling.test.mjs serves a running crawl with a second result page, a 429 on the second status read, then completion; it fails on main with the 429 and passes here (full suite passes).

Open in Capy


Summary by cubic

Fixes firecrawl_crawl polling so a healthy crawl no longer fails the tool.

  • Polls only the first status page while the crawl runs and collects result pages once it reaches completed, failed or cancelled, reusing the terminal poll's response as the first result page.
  • A 429 on a status read now waits for Retry-After (seconds or HTTP-date, or retry_after_seconds, default 10s, capped at 60s) and keeps polling; other errors still fail as before.

Written for commit 1e39bf9. Summary will update on new commits.

View guided diff Turn on auto-fix

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread tests/mcp-crawl-polling.test.mjs
Comment thread src/server.ts Outdated
Comment thread src/server.ts Outdated

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

0 issues found across 2 files (changes from recent commits).

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Auto-approved: Makes crawl polling resilient: polls only the first status page while running, collects result pages once at termination, and retries 429 status reads via Retry-After; the added test pins this behavior, so the change is bounded and clearly beneficial.

View guided diff | Turn on auto-fix | Re-trigger cubic

@capy-ai
capy-ai Bot merged commit 0b93f4e into main Oct 19, 2026
2 checks passed
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.

1 participant