Skip to content

fix(streams): bound orphaned admin connections#212

Merged
DavidBabinec merged 10 commits into
mainfrom
fix/plugin-event-stream-cleanup
Jul 11, 2026
Merged

fix(streams): bound orphaned admin connections#212
DavidBabinec merged 10 commits into
mainfrom
fix/plugin-event-stream-cleanup

Conversation

@DavidBabinec

@DavidBabinec DavidBabinec commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

What changed

  • make plugin event-stream teardown idempotent across request aborts, response-consumer cancellation, and failed writes
  • remove plugin broadcaster subscribers and heartbeat timers on every disconnect path
  • give both the MCP editor bridge and plugin event stream a two-minute server-side lease so orphaned intermediary connections cannot live indefinitely
  • rely on the existing client reconnect loops to restore deliberately leased streams
  • add server regressions for direct response cancellation and 100 repeated plugin stream connect/cancel cycles

Why

Bun can report a disconnected response consumer through ReadableStream.cancel() without aborting the server Request, and an intermediary may fail to propagate the downstream disconnect at all. Without a bounded lifetime, repeated admin contexts can accumulate orphaned long-lived streams and eventually exhaust available proxy connections. Idempotent teardown handles observable disconnects immediately; the lease bounds the remaining intermediary-orphan case.

Verification

  • bun test — 6,229 pass, 0 fail
  • focused MCP editor bridge and plugin event-stream tests — 7 pass, 0 fail
  • bun run lint
  • bunx tsc --noEmit
  • bun run build

@DavidBabinec DavidBabinec changed the title fix(plugins): clean up disconnected event streams fix(dev): prevent disconnected streams from exhausting the proxy Jul 11, 2026
@DavidBabinec DavidBabinec changed the title fix(dev): prevent disconnected streams from exhausting the proxy fix(streams): bound orphaned admin connections Jul 11, 2026
@DavidBabinec DavidBabinec merged commit 2e8a6df into main Jul 11, 2026
9 checks passed
@DavidBabinec DavidBabinec deleted the fix/plugin-event-stream-cleanup branch July 11, 2026 18:09
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