Repository navigation
[PR] fix(ws-bridge): re-arm wss lazily after a post-bind ladder re-listen - #7047
ranxianglei wants to merge 1 commit into
Conversation
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.10792-pr.7047.256b3ffThis exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr7047.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 查重: 同家族但机制不同 — 本 PR (#7047) 修 #7046(ladder re-listen 后 WS 车道永久 503,启动期换端口触发);与 #7018 同属「WS bridge 车道失效」家族、同改 独立核验(不照抄 issue/前次结论)拉了 PR 分支
结构化八问
|
…7046) The #2941 post-bind ladder closes the bound port and re-listens the SAME http.Server object. The bridge's 'close' backstop runs wss.close(), and the ws library never reopens a closed WebSocketServer — every later upgrade 503s (completeUpgrade: _state > RUNNING) for the rest of the process, permanently killing the WS compression lane (opencode/codex responses). Re-arm lazily in the upgrade handler: track a wssDead flag set by the 'close' backstop; on the first upgrade after a re-listen, create a fresh wss before handleUpgrade. The 'listening' event can't be used because attemptListen (server.ts) strips all 'listening' listeners before each listen. The ladder path has already cut every connection (closeAllConnections), so no live session is lost. Regression test: installWebSocketBridge → listen(0) → close + closeAllConnections → re-listen(0) (mirroring attemptListen's removeAllListeners('listening')) → real loopback WS upgrade → assert echo. Fails with 503 before the fix, passes after.
32b7136 to
a3d80e4
Compare
(ai: vllm-qwen/qwen3.8-27b) Conflict resolved and pushed. Rebased the PR branch onto current master ( Where it conflicted: Important — the pure textual union was NOT enough. After uniting both intents, the PR's own regression test failed locally ( What I did about it: moved the re-arm to the top of the upgrade handler (it must run BEFORE the Local verification (targeted, per local-test discipline): 结构化八问:
判定:冲突已解、已推送( |
Summary
Fixes #7046
The #2941 post-bind ladder closes the bound port and re-listens the SAME http.Server object. The bridge's 'close' backstop runs
wss.close(), and the ws library never reopens a closed WebSocketServer — every later upgrade 503s (completeUpgrade:_state > RUNNING) for the rest of the process, permanently killing the WS compression lane (opencode/codex responses).Fix
Re-arm lazily in the upgrade handler: track a
wssDeadflag set by the 'close' backstop; on the first upgrade after a re-listen, create a freshwssbeforehandleUpgrade. The 'listening' event can't be used becauseattemptListen(server.ts) strips all 'listening' listeners before each listen. The ladder path has already cut every connection (closeAllConnections), so no live session is lost.Regression test
tests/ws-bridge.test.ts: installWebSocketBridge → listen(0) → close + closeAllConnections → re-listen(0) (mirroring attemptListen'sremoveAllListeners('listening')) → real loopback WS upgrade → assert echo. Fails with 503 before the fix, passes after.