Skip to content

fix(plugins): stop AbortSignal.any leaking a cell per plugin call - #240

Merged
mistakeknot merged 2 commits into
mainfrom
fix/abortany-lifetime-leak
Nov 15, 2026
Merged

mistakeknot merged 2 commits into
mainfrom
fix/abortany-lifetime-leak

Conversation

@mistakeknot

Copy link
Copy Markdown
Owner

Fixes bead mk-gzfpf.11.2.1.1.

invokeWrapped combined the caller signal with the plugin lifetime signal using AbortSignal.any. Node registers each source in an internal registry, and cells for a long-lived source are only freed when it is collected, so every HTTP plugin RPC and plugin CLI call leaked about 176 B until the plugin stopped.

This replaces it with linkAbortSignals: a per-call AbortController with abort listeners on both signals, removed in finally. It aborts immediately if either signal is already aborted.

Tests: apps/server/test/services/plugins/linked-abort.test.ts covers caller abort, lifetime abort, pre-aborted sources, and lifetime listener count returning to baseline after 5,000 calls. Targeted plugin tests and @bb/server typecheck pass.

🤖 Generated with Claude Code

mistakeknot and others added 2 commits November 14, 2026 21:07
… call

invokeWrapped combined the caller signal with the plugin lifetime signal via
AbortSignal.any, which leaves one Node cleanup-registry cell (~176 B) per
call until the plugin stops. Use a per-call controller with abort listeners
on both signals, removed in finally. Bead mk-gzfpf.11.2.1.1.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Comment-only change; no behaviour difference. Bead mk-gzfpf.11.2.1.1.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@mistakeknot
mistakeknot merged commit f5397d9 into main Nov 15, 2026
2 checks passed
@mistakeknot
mistakeknot deleted the fix/abortany-lifetime-leak branch November 15, 2026 03:19
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