Repository navigation
Contain stack-less uncaught errors from work a plugin started - #7849
Merged
Merged
Conversation
An aborted fetch rejects with an AbortError whose stack names no code: no frames at all on Node 24 (the desktop runtime) and only an undici frame on Node 22, because undici re-captures the stack after an await. When a plugin left such a rejection unhandled, the server could not find a plugin location in the stack and exited (get-bb#7509). Run the plugin's module import, factory and every wrapped invocation in an AsyncLocalStorage context that names the plugin. The uncaught handler still decides by stack location first. Only when the stack names no code outside node: internals does it fall back to that context, so a core error with frames, including core work started during a plugin call, still exits the server.
lanjak
force-pushed
the
fix-7509-frameless-abort-error
branch
from
November 19, 2026 19:01
69a3cc4 to
2906be1
Compare
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
The server's
uncaughtExceptionhandler exits unless the plugin runtime claims the error (start-server.ts#L606-L612). Outside a service run, the runtime claims an error only when a loaded plugin's code file appears in its stack (plugin-runtime.ts#L610-L645).The error in #7509 is what an aborted
fetchrejects with. undici re-captures the stack after anawait. The result isAbortError: This operation was abortedwith no frames on Node 24, which the desktop app runs, and with only annode:internal/deps/undiciframe on Node 22. undici also rewrites the stack of the sharedsignal.reason, so anything else that later throws that reason has the same stack. When plugin code leaves such a rejection unhandled, the stack names no plugin and the server exits. This is how one plugin's floating aborted fetch can restart the whole server several times a day.What changed
apps/server/src/services/plugins/plugin-runtime.ts:AsyncLocalStorage,pluginCodeContext, names the plugin. It is set around the plugin's module import, its factory andinvokeWrapped, which every handler, hook, provider, RPC, route, CLI and event call goes through.uncaughtExceptionhandler in the async context of the throwing callback or the rejected promise, so the handler can read it.containPluginErrorstill decides by stack location first. Only when the stack names no code outsidenode:internals does it fall back to that context.[plugin:<id>] uncaught error from work this plugin started (its stack names no code): ..., and the plugin's status detail is set as before.How you verified
apps/server/test/services/plugins/plugin-instance-lifecycle.test.ts, "contains an aborted fetch's frameless error from work a plugin started". The fixture plugin aborts a realfetchto a local server that never answers and rethrows the rejection from a detached callback. On main it fails: 0 errors claimed. With the change, 1 is claimed and the plugin staysrunningwith the message in its status detail.node:, and the handler sees the plugin's context. The server test suite itself only runs on the Node 24 build here.pnpm exec turbo run test --filter=@bb/server -- test/services/plugins test/pluginspasses (61 files, 603 tests).pnpm exec turbo run typecheck lint lint:type-aware --filter=@bb/serverpasses, andoxfmtis clean.Fixes #7509