Repository navigation
fix(responses): bound closing handshakes for non-reused upstream WebSockets (carry #7681) - #7743
Conversation
…ockets Carry of #7681 onto current dev. A private (non-retained) Codex WebSocket now gets a one-second graceful close window, after which the native socket is terminated; retained-pool disposal stays immediate and successful pooled release stays reusable. Co-authored-by: luvs01 <27862058+luvs01@users.noreply.github.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Socket teardown behavior src/server/responses/codex-ws-session.ts, structure/transports/responses-wire-shapes.md |
dispose delegates socket cleanup to closeSessionSocket. Private sockets use a one-second grace period before termination; retained sockets close and terminate immediately on disposal. The documentation describes socket reuse conditions and disposal behavior. |
Teardown validation tests/responses/codex-ws-handshake-validation.test.ts |
Tests cover timer scheduling and cleanup, socket and owner errors, retained-session reuse, and a real peer that withholds its close reply. |
Priority:
Estimated code review effort: 2 (Simple) | ~15 minutes
Change: Bug fix
Possibly related PRs
- lidge-jun/opencodex#7635: Applies a similar graceful-close timeout and forced termination pattern to live-sideband teardown.
Suggested labels: bug
Suggested reviewers: luvs01
Merge Risk: 
Minimal · up to 944fd
-
Private sockets receive the intended close window, and retained sockets dispose immediately. No actionable merge-blocking risk was established.
Pre-merge checks: 
5
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (1 skipped: 1 unsupported.)
-
Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
|
✅ Deterministic PR hygiene checks passed. |
|
Maintainer integration decision for v2.93.0 (lane L-D1): merging into
This carries #7681 by @luvs01; the squash keeps the Co-authored-by trailer. |
Summary
Carries #7681 by @luvs01 onto current
dev(the original is a 23-behind author draft). When a Codex Responses WebSocket that will not be reused is disposed, the proxy now asks for a graceful close and, if the peer never answers the closing handshake, terminates that native socket after one second. Before this, Bun 1.4.4 could leave a private upstream socket waiting indefinitely on an unresponsive peer.Retained-pool disposal keeps its immediate close-and-terminate, and a successful pooled release stays reusable. The close timer and listener are cleaned up on early close, timeout and exceptions; a socket without native
terminate()only receives a close attempt. The owning wire contract instructure/transports/responses-wire-shapes.mddescribes the behavior, andtests/responses/codex-ws-handshake-validation.test.tsadds native loopback stalled-peer, receipt, cancellation and ownership regressions.The source change is byte-identical to #7681's dev-relative diff (3 files); only the base moved.
Verification
Run on Windows with pinned Bun 1.4.4 on this exact tree (
944fdbb31e, parentorigin/devc2f3d8b42be):bun testover all 19tests/responses/*ws*files: 575 pass, 1 existing conditional skip, 0 fail.bun x tsc --noEmit: exit 0.bun run structure:check: passed.tests/ci-workflows/file-size-ratchet.test.ts: 9 pass.Full local suite NOT RUN (shared-host resource exception; hosted Ubuntu shards and a
lane=alldispatch on this head cover the rest). #7681's description records an older broadtest:changedrun on Bun 1.4.3 with failures that were never classified; the hosted shards on this head are the current evidence for that.Checklist
Supersedes #7681.
Co-authored-by: luvs01 27862058+luvs01@users.noreply.github.com
Summary by CodeRabbit