Skip to content

fix: stop agent --wait polling when the job is cancelled - #297

Open
flcrom wants to merge 2 commits into
firecrawl:mainfrom
flcrom:fix/agent-cancelled-wait
Open

flcrom wants to merge 2 commits into
firecrawl:mainfrom
flcrom:fix/agent-cancelled-wait

Conversation

@flcrom

@flcrom flcrom commented Oct 1, 2026 •

Copy link
Copy Markdown

firecrawl agent "<prompt>" --wait keeps polling after the server reports the job as cancelled, so it never returns without --timeout, and with one it exits 1 with "Agent still processing". Checking an existing job id with --wait already stops on cancelled; this makes the start-and-wait path do the same: exit 0 with the cancelled status and data.

Only the polling loop changes (8 lines). Completed, failed, processing and timeout behavior is unchanged.

Added agent-cancellation.test.ts (6 cases against a local HTTP fixture). The two cancellation cases fail on current main. pnpm test, build, type-check and format:check pass locally.

AI help was used for this change.


Summary by cubic

Stops firecrawl agent "<prompt>" --wait from polling forever when the job is cancelled. Previously it only stopped on completed/failed, so a cancelled job kept polling until timeout or exited with "Agent still processing". Now the start-and-wait path matches the existing-job path: it exits 0 with the cancelled status and data. Only the polling loop changes; completed, failed, processing, and timeout behavior are unchanged.

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

Review in cubic

@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.

1 issue found across 2 files

Confidence score: 4/5

  • On a clean checkout, agent-cancellation.test.ts spawns dist/index.js, but pnpm test does not build it, so the cases fail with ENOENT. Build the CLI as part of the test setup.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/__tests__/commands/agent-cancellation.test.ts">

<violation number="1" location="src/__tests__/commands/agent-cancellation.test.ts:56">
P3: This test spawns the compiled `dist/index.js`, but `pnpm test` (`vitest run`) builds nothing, so on a clean checkout the CLI spawn fails with ENOENT and every case errors out — or, after unrelated source edits, the suite quietly tests a stale build. Build the project before running the suite (e.g., a `pretest` script or CI `build` step) or have `cli()` fail with a clear message when `dist/` is missing.</violation>
</file>

Shadow auto-approve: would auto-approve with 1 open P3 issue. Bounded fix to stop firecrawl agent --wait from polling forever when a job is cancelled: the start-and-wait path now exits 0 with cancelled status/data, matching the existing-job path; adds cancellation tests against a local HTTP fixture.

Fix all with cubic | Re-trigger cubic

...(await exec(
process.execPath,
[
'dist/index.js',

@cubic-dev-ai cubic-dev-ai Bot Oct 1, 2026 •

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.

P3: This test spawns the compiled dist/index.js, but pnpm test (vitest run) builds nothing, so on a clean checkout the CLI spawn fails with ENOENT and every case errors out — or, after unrelated source edits, the suite quietly tests a stale build. Build the project before running the suite (e.g., a pretest script or CI build step) or have cli() fail with a clear message when dist/ is missing.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At src/__tests__/commands/agent-cancellation.test.ts, line 56:

<comment>This test spawns the compiled `dist/index.js`, but `pnpm test` (`vitest run`) builds nothing, so on a clean checkout the CLI spawn fails with ENOENT and every case errors out — or, after unrelated source edits, the suite quietly tests a stale build. Build the project before running the suite (e.g., a `pretest` script or CI `build` step) or have `cli()` fail with a clear message when `dist/` is missing.</comment>

<file context>
@@ -0,0 +1,126 @@
+      ...(await exec(
+        process.execPath,
+        [
+          'dist/index.js',
+          'agent',
+          prompt,
</file context>
Fix with cubic

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