Repository navigation
Description
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:
maxConcurrentAgents16,maxAgentCalls1000
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
wsgp2 commentedon Nov 29, 2026
Follow-up with results:
try/catcharoundreader.cancel(error)atstart-server.js:180372does NOT help. With the patch loaded, the next crash came from inside thetryblock (start-server.js:180373:14) — theAbortErroris not thrown synchronously bycancel(); it surfaces later as an uncaught exception with the same stack.Guarding the process-level handler does help. In
start-server.js(process.on("uncaughtException", …), the only handler that callsprocess.exit(1)), we skip errors withcode === "ABORT_ERR"whose stack containswebstreams/adapters/ServerResponse.cancel:With this, a 16-agent workflow run completed successfully; the same server process absorbed 16 of these AbortErrors in ~2 minutes without restarting. The
uncaughtExceptionMonitordiagnostic 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
errorhandler to the underlying Node stream beforeReadable.toWeb, or catch it in the hono adapter), and/or to avoid stopping a workflow worker while itsbb_workflow_resulttool call is still in flight. Also worth noting how frequent it is: ~1 per worker in a 16-agent run.bb-slop-cop commentedon Nov 29, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilothost,workflows,no-repro.origin/main, so no failing regression supports a safe production fix.wsgp2 commentedon Nov 29, 2026
Root cause found + verified local fix (bb-app 0.50.1, Node 26.4.0, macOS)
The earlier workaround (ignoring
ABORT_ERRin theuncaughtExceptionhandler) 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_resulttool 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 doesawait l0(threadId)(stopChild→threads.stop) before returning{ok:true}. The daemon cancels the in-flight/internal/session/tool-callfetch (thread.stop → cancelThread → AbortController.abort) →Failed to forward dynamic tool call to serverin 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.
streamToolCallResponsereturns aReadableStreamwith noCache-Control: no-transform, so honocompress()pipes it throughCompressionStream. On abort,pipeThroughproduces an unhandled rejection inside Node's webstreams (readablestream.js~1630/1734). The server has nounhandledRejectionlistener, so under the default--unhandled-rejections=throwit becomesuncaughtException→process.exit(1). (The diagnostics writer onuncaughtExceptionMonitordoesn't recordorigin, so the files sayuncaughtException; in a repro the origin isunhandledRejection.) 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:
server/dist/start-server.js,streamToolCallResponse:headers: { "content-type": "application/json; charset=UTF-8", "cache-control": "no-transform" }— tool-call responses skip compression.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 (andcleanupWorkers→archiveRetiredWorkerstill retires it if the timer is lost on restart).Result after server restart: 9 schema
agent()results delivered viabb_workflow_resultacross live runs, 0 newprocess-server-uncaughtException-*files, 0Failed to forward dynamic tool calllines, 0 new hits of theABORT_ERRworkaround (before: ~100 crash files overnight, every one within ±3 s of aFailed to forward … bb_workflow_resultline).Suggested upstream fixes: stop the worker after
PluginToolCallRegistry.runhas settled the response (not insideexecute); mark tool-call responsesno-transformor don'tenqueueafter abort; and anunhandledRejectionlistener so one aborted stream can't take the whole server down.fix(server): keep held-open tool-call responses out of compression (g…
fix(server): keep held-open tool-call responses out of compression (g…