Skip to content

process-server crash loop: unhandled AbortError on streamed response cancel (workflows worker stop during bb_workflow_result), Node 26 #8332

Description

@wsgp2

What happens

The bb process-server crashes with an uncaughtException (AbortError: The operation was aborted, code: ABORT_ERR) whenever a streamed response is cancelled mid-flight. With the workflows plugin running, this turns into a crash loop: we saw 35 crashes in 80 minutes (roughly one per minute). Each crash kills every running thread; the workflow engine then re-creates its worker threads from scratch, which burns subscription quota without results.

Environment

  • bb-app 0.50.1 (npm, latest), macOS (Apple Silicon)
  • Node v26.4.0 (Homebrew)
  • Providers: codex (account pool) and claude-code
  • workflows plugin: maxConcurrentAgents 16, maxAgentCalls 1000

Stack (identical in all 35 process-server-uncaughtException-*.json files)

AbortError: The operation was aborted
    at destroyer (node:internal/streams/destroy:328:11)
    at Object.cancel (node:internal/webstreams/adapters:498:7)
    at Object.cancelAlgorithm (node:internal/webstreams/util:191:25)
    at readableStreamDefaultControllerCancelSteps (node:internal/webstreams/readablestream:2602:37)
    at [kCancel] (node:internal/webstreams/readablestream:1174:12)
    at readableStreamCancel (node:internal/webstreams/readablestream:2165:39)
    at readableStreamReaderGenericCancel (node:internal/webstreams/readablestream:2308:10)
    at ReadableStreamDefaultReader.cancel (node:internal/webstreams/readablestream:976:12)
    at ServerResponse.cancel (.../bb-app/server/dist/start-server.js:180372:12)
    at ServerResponse.emit (node:events:521:24)

start-server.js:180372 is the bundled @hono/node-server writeFromReadableStreamDefaultReader: on the response close event it calls reader.cancel(error).

Trigger (correlated within ±3 s for all 35 crashes)

Each crash coincides with a host-daemon log line Failed to forward dynamic tool call to server for tool bb_workflow_result, every time from a different worker thread of a running workflow. It looks like the workflow engine stops the worker thread (thread.stop) right as the worker submits its result; the daemon aborts the /session/tool-call request, the server cancels the streamed response, and the cancellation surfaces as an unhandled AbortError that takes the whole process down.

With no workflow runs active, the server ran 2.5+ h without a single crash (threads and automations kept working).

Expected

A client disconnecting from a streamed response should not crash the server: the cancellation should be caught/handled (e.g. a try/catch around reader.cancel() plus an error listener on the underlying Node stream), and ideally the workflow engine should not stop a worker while its bb_workflow_result tool call is still in flight.

Workaround we are testing

Wrapping the reader.cancel(error) call at start-server.js:180372 in try/catch. We are not yet sure it is sufficient: if Node emits the error later as an error event instead of throwing synchronously, the try/catch will not catch it. We will follow up with the result.

Activity

  1. added theissue type on Nov 29, 2026
  2. added
    host
    workflows
    on Nov 29, 2026
  3. wsgp2 commented on Nov 29, 2026

    @wsgp2
    Author

    Follow-up with results:

    1. try/catch around reader.cancel(error) at start-server.js:180372 does NOT help. With the patch loaded, the next crash came from inside the try block (start-server.js:180373:14) — the AbortError is not thrown synchronously by cancel(); it surfaces later as an uncaught exception with the same stack.

    2. Guarding the process-level handler does help. In start-server.js (process.on("uncaughtException", …), the only handler that calls process.exit(1)), we skip errors with code === "ABORT_ERR" whose stack contains webstreams/adapters / ServerResponse.cancel:

    process.on("uncaughtException", (error) => {
      if (error && error.code === "ABORT_ERR" &&
          /webstreams\/adapters|ServerResponse\.cancel/.test(String(error.stack || ""))) {
        process.stderr.write("ignored AbortError from cancelled streamed response\n");
        return;
      }
      if (pluginService.handleUncaughtException(error)) return;
      // ... original: write stack, process.exit(1)
    });

    With this, a 16-agent workflow run completed successfully; the same server process absorbed 16 of these AbortErrors in ~2 minutes without restarting. The uncaughtExceptionMonitor diagnostic files are still written for each one (so the files alone are no longer a crash signal — a crash is a pid change).

    This is obviously a workaround, not a fix: the real fix is probably to handle the cancellation of the streamed tool-call response (attach an error handler to the underlying Node stream before Readable.toWeb, or catch it in the hono adapter), and/or to avoid stopping a workflow worker while its bb_workflow_result tool call is still in flight. Also worth noting how frequent it is: ~1 per worker in a 16-agent run.

  4. added
    no-repro
    on Nov 29, 2026
  5. bb-slop-cop commented on Nov 29, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Classification: Bug · Priority High · Effort Medium; labels: host, workflows, no-repro.
    • Reproduction and root-cause report: NOT REPRODUCED, root-cause confidence low.
    • Evidence: two clean trusted-main checkouts survived 800 transport disconnects and six authenticated tool-route cancellation tests, including gzip/deflate; eight relevant existing tests also passed.
    • Root cause remains unconfirmed. Worker result handling does await stopping its own thread before replying, but the tested cancellation paths did not produce an escaping stream error.
    • Limit: tested Linux x64 with Node 22.19.0 and 26.13.1, not the reported macOS ARM64 / Node 26.4.0 combination. This does not establish that the reported crash is absent or fixed.
    • No pull request: the crash was not reproduced on trusted origin/main, so no failing regression supports a safe production fix.
  6. wsgp2 commented on Nov 29, 2026

    @wsgp2
    Author

    Root cause found + verified local fix (bb-app 0.50.1, Node 26.4.0, macOS)

    The earlier workaround (ignoring ABORT_ERR in the uncaughtException handler) only kept the server alive. We traced the actual cause; it takes two conditions at once:

    1. The workflows engine stops the worker from inside its own bb_workflow_result tool call.
    builtin-plugins/workflows/dist/server.js, submitStructuredResult: after the result is stored (en), the call is marked succeeded (gx) and the script is woken (R0), it does await l0(threadId) (stopChild → threads.stop) before returning {ok:true}. The daemon cancels the in-flight /internal/session/tool-call fetch (thread.stop → cancelThread → AbortController.abort) → Failed to forward dynamic tool call to server in host-daemon logs. The result itself is never lost — only the response stream to an already-stopped worker.

    2. The cancelled response is compressed, and Node 26.4.0 turns that abort into a crash.
    streamToolCallResponse returns a ReadableStream with no Cache-Control: no-transform, so hono compress() pipes it through CompressionStream. On abort, pipeThrough produces an unhandled rejection inside Node's webstreams (readablestream.js ~1630/1734). The server has no unhandledRejection listener, so under the default --unhandled-rejections=throw it becomes uncaughtException → process.exit(1). (The diagnostics writer on uncaughtExceptionMonitor doesn't record origin, so the files say uncaughtException; in a repro the origin is unhandledRejection.) Repro on Node v26.4.0: with compression 20/20 uncaught, without compression 0/20.

    Local fix (two text replacements), applied 29.11 05:05 UTC:

    1. server/dist/start-server.js, streamToolCallResponse: headers: { "content-type": "application/json; charset=UTF-8", "cache-control": "no-transform" } — tool-call responses skip compression.
    2. builtin-plugins/workflows/dist/server.js, submitStructuredResult (accepted, idempotent and corrections-exhausted branches): await l0(c) → setTimeout(()=>{l0(c).catch(()=>{})},3e3) — the tool response goes out first, the worker is stopped 3 s later (and cleanupWorkers → archiveRetiredWorker still retires it if the timer is lost on restart).

    Result after server restart: 9 schema agent() results delivered via bb_workflow_result across live runs, 0 new process-server-uncaughtException-* files, 0 Failed to forward dynamic tool call lines, 0 new hits of the ABORT_ERR workaround (before: ~100 crash files overnight, every one within ±3 s of a Failed to forward … bb_workflow_result line).

    Suggested upstream fixes: stop the worker after PluginToolCallRegistry.run has settled the response (not inside execute); mark tool-call responses no-transform or don't enqueue after abort; and an unhandledRejection listener so one aborted stream can't take the whole server down.

  7. added a commit that references this issue on Nov 30, 2026
    b88c387
  8. added a commit that references this issue on Dec 1, 2026
    5ac2f6b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    hostno-reproworkflows

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions