Skip to content

Close retired RPC connections after draining replies - #690

Merged
ualtinok merged 2 commits into
mainfrom
fix/rpc-stop-connections
Nov 9, 2026
Merged

ualtinok merged 2 commits into
mainfrom
fix/rpc-stop-connections

Conversation

@antauth-alfonso

@antauth-alfonso antauth-alfonso Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Close retired RPC connections after draining replies. Worker delivery rebased onto main; see the commit messages.


Summary by cubic

Fixes a stale-connection race where the OpenCode TUI's /claude menu briefly errored with "unauthorized" or a dropped connection after a plugin reload.

  • Stop now marks draining responses Connection: close and destroys all remaining owned sockets after replies drain.
  • The connection-pool opt-out (keepalive) is preserved through the loopback network guard and across redirects.
  • Adds deterministic tests for stop draining and pool opt-out preservation.

Written for commit 5e4ba50. Summary will update on new commits.

View guided diff Turn on auto-fix

Bun closes already-idle HTTP sockets on server.close, but sockets active at stop can remain reusable after replying. A TUI request following a reload can then reach the retired RPC dispatcher and receive unauthorized instead of reaching the successor. Mark draining replies Connection: close and destroy/await all remaining owned sockets after the native close callback drains replies.

Keep short-lived info-log RPC fixtures out of Bun's pool and preserve that fetch option through the loopback guard, including redirects. Add deterministic regressions: old RPC source reaches the retired dispatcher after stop; old guard loses the pool opt-out and produces ECONNRESET. The original release log does not record port/socket reuse, so its exact ordering is not claimed as observed.
@ualtinok
ualtinok merged commit 5e4ba50 into main Nov 9, 2026
16 checks passed
@ualtinok
ualtinok deleted the fix/rpc-stop-connections branch November 9, 2026 21:15
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