Repository navigation
Conversation
The internal tool-call route streams its body so the daemon gets response headers before a long plugin tool finishes. Hono's compress() wrapped that stream in a CompressionStream. When the daemon cancels the request (thread stop), the registry settles the call on the same abort, so the source closes while node-server cancels the compressed reader. On Node 26.4-26.6 that race leaves an unhandled AbortError rejection, which the server's uncaughtException handler turns into process.exit(1). Mark the response no-store, no-transform, as the plugin CLI keepalive stream already does. Fixes #8332 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This comment has been minimized.
This comment has been minimized.
ymichael
deleted the
bb/8332-process-server-crash-loop-unhandled-aborter-thr_fwi4z4ak52
branch
November 30, 2026 21:54
scowalt
pushed a commit
to scowalt/bb
that referenced
this pull request
Dec 1, 2026
…et-bb#8407) ## Human comments ## What was wrong `POST /internal/session/tool-call` streams its body so the daemon receives the response head before a long-running plugin tool finishes (get-bb#1084). The app-wide Hono `compress()` middleware wrapped that held-open stream in a `CompressionStream`. When the daemon cancels the request (for example, a thread stop during a plugin tool call), `PluginToolCallRegistry` settles the call synchronously on the same abort. The source therefore enqueues and closes while `@hono/node-server` cancels the compressed reader. On Node 26.4.0–26.6.0, that race leaves an unhandled `AbortError` rejection (`destroyer` → `webstreams/adapters:498` → `ServerResponse.cancel`). Under the default `--unhandled-rejections=throw`, the server's `uncaughtException` handler then calls `process.exit(1)`. Node 26.7.0 fixed the race upstream; 22.x, 26.3.1 and 26.7+ are unaffected. get-bb#8376 removed the most frequent trigger, the workflows engine stopping a worker during `bb_workflow_result`. Any thread stop during an in-flight plugin tool call still crashed affected Node versions. ## What changed - `apps/server/src/internal/tool-calls.ts`: the streamed tool-call response sets `cache-control: no-store, no-transform`, so compression skips it. The plugin CLI keepalive stream in `routes/plugins.ts` already uses the same header. The body is one small JSON chunk that gzip could not emit before the call settled anyway. - `apps/server/test/internal/internal-events-tool-calls.test.ts`: new real-socket test. It starts a pending plugin tool call with `accept-encoding: gzip, deflate`, asserts the response is not content-encoded, aborts the request as the daemon does, and waits for the plugin's signal to abort. There is no wire or protocol change: the daemon already accepted uncompressed responses. ## How you verified - Standalone hono + `compress()` + `@hono/node-server` repro: Node 26.4.0, 26.5.0 and 26.6.0 crash on 20/20 cancels with compression and 0/20 without it. Node 22.23.1, 26.3.1, 26.7.0, 26.8 and 26.12.1 are 0/20 in both modes. - New test before the fix: fails on Node 22 (`content-encoding: gzip`). With the encoding assertion skipped, Node 26.4.0 reports the issue's exact unhandled `AbortError` stack through the real route. - After the fix on Node 26.4.0: `internal-events-tool-calls.test.ts` and `internal-tool-call-regressions.test.ts` pass (37 tests) with no unhandled errors. - `pnpm exec turbo run typecheck lint --filter=@bb/server` passes. - `pnpm exec turbo run test --filter=@bb/server -- test/internal/internal-events-tool-calls.test.ts test/internal/internal-tool-call-regressions.test.ts test/services/plugins/plugin-agent-tools.test.ts` passes (57 tests). Fixes get-bb#8332 > AGENT GENERATED 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
POST /internal/session/tool-callstreams its body so the daemon receives the response head before a long-running plugin tool finishes (#1084). The app-wide Honocompress()middleware wrapped that held-open stream in aCompressionStream. When the daemon cancels the request (for example, a thread stop during a plugin tool call),PluginToolCallRegistrysettles the call synchronously on the same abort. The source therefore enqueues and closes while@hono/node-servercancels the compressed reader. On Node 26.4.0–26.6.0, that race leaves an unhandledAbortErrorrejection (destroyer→webstreams/adapters:498→ServerResponse.cancel). Under the default--unhandled-rejections=throw, the server'suncaughtExceptionhandler then callsprocess.exit(1). Node 26.7.0 fixed the race upstream; 22.x, 26.3.1 and 26.7+ are unaffected. #8376 removed the most frequent trigger, the workflows engine stopping a worker duringbb_workflow_result. Any thread stop during an in-flight plugin tool call still crashed affected Node versions.What changed
apps/server/src/internal/tool-calls.ts: the streamed tool-call response setscache-control: no-store, no-transform, so compression skips it. The plugin CLI keepalive stream inroutes/plugins.tsalready uses the same header. The body is one small JSON chunk that gzip could not emit before the call settled anyway.apps/server/test/internal/internal-events-tool-calls.test.ts: new real-socket test. It starts a pending plugin tool call withaccept-encoding: gzip, deflate, asserts the response is not content-encoded, aborts the request as the daemon does, and waits for the plugin's signal to abort.There is no wire or protocol change: the daemon already accepted uncompressed responses.
How you verified
compress()+@hono/node-serverrepro: Node 26.4.0, 26.5.0 and 26.6.0 crash on 20/20 cancels with compression and 0/20 without it. Node 22.23.1, 26.3.1, 26.7.0, 26.8 and 26.12.1 are 0/20 in both modes.content-encoding: gzip). With the encoding assertion skipped, Node 26.4.0 reports the issue's exact unhandledAbortErrorstack through the real route.internal-events-tool-calls.test.tsandinternal-tool-call-regressions.test.tspass (37 tests) with no unhandled errors.pnpm exec turbo run typecheck lint --filter=@bb/serverpasses.pnpm exec turbo run test --filter=@bb/server -- test/internal/internal-events-tool-calls.test.ts test/internal/internal-tool-call-regressions.test.ts test/services/plugins/plugin-agent-tools.test.tspasses (57 tests).Fixes #8332
🤖 Generated with Claude Code