fix(crawl): return pages for a job ID, resume --wait by ID, exit 1 when a waited crawl fails
RA
17h ago+282+282+012345678901234567890123456789-123-123-012345678901234567890123456789
Three gaps made a detached crawl unusable from scripts and agents:
firecrawl crawl <job-id>printed only{id, status, total, completed, creditsUsed, expiresAt}and dropped the pages, so a crawl started without--waitcould never be read back from the CLI.firecrawl crawl <job-id> --waitdidn't wait: the status branch ran before the wait logic.crawl --waitexited 0 when the crawl endedfailedorcancelled; the status was only visible inside the JSON.
Now:
- Job ID:
crawl <id>(or--status) prints the full job fromgetCrawlStatus, includingdata(the pages collected so far, auto-paginated by the SDK) andnext.-oand--prettyapply as for a completed crawl. - Resume:
crawl <id> --waitpolls that job until it'scompleted,failedorcancelled, honouring--poll-interval,--timeout(both must be positive numbers) and--progress. Each poll fetches one status page, and all pages are fetched once the job ends. A timeout prints the command to resume with. - Exit status: with
--wait, a crawl that endsfailedorcancelledstill prints the job JSON, then writesError: Crawl <status>.to stderr and exits 1. Reading a job's status without--waitkeeps exit 0 whatever the status, and a successful--cancelexits 0 even with--wait. - The unused human-readable status formatter (its guard could never be true) and the
CrawlStatusResulttype are removed;--helpdescribes the job ID and--waitbehaviour.
Show me (local mock API, a job that ends failed with one page)
$ firecrawl crawl 2222…2222
{"id":"2222…2222","status":"failed","completed":1,"total":3,…,"data":[{"markdown":"p1","metadata":{"sourceURL":"https://a.com"}}]}
exit=0
$ firecrawl crawl 2222…2222 --wait
{… same job …}
Error: Crawl failed.
exit=1
$ firecrawl crawl https://a.com --wait
{… same job …}
Error: Crawl failed.
exit=1
Validation
pnpm run type-check,pnpm run buildandpnpm testpass (836 tests); prettier clean on the changed files.- New tests: a job ID returns its pages;
--waiton a job ID polls to a terminal status without starting a crawl; a timeout names the resume command; a waited crawl that endsfailedorcancelledprints the job and sets exit code 1; reading a failed job without--wait, or cancelling with--wait, leaves the exit code alone; waits poll one page at a time; invalid wait flags are rejected before polling.
Summary by cubic
Fixes three gaps in the firecrawl crawl CLI that made detached crawls hard to use from scripts and agents.
crawl <job-id>now prints the full job from the status endpoint, including collected pages (data) andnext, instead of a stripped-down summary.crawl <job-id> --waitpolls the existing job to a terminal status instead of returning immediately; a timeout prints the resume command to rerun, and--progressshows live progress while waiting.- A waited crawl that ends
failedorcancellednow exits 1 and writesError: Crawl <status>.to stderr, while reading status without--wait, or cancelling with--wait, keeps exit 0. --poll-intervaland--timeoutare validated as positive numbers before a wait starts.- Removed the unused human-readable status formatter and
CrawlStatusResulttype, and updated--helptext to describe the job ID and--waitbehavior.