Repository navigation
fix(diagnostics): wait for server close in WebSocket test, cover quiet shutdown, evict LRU - #1838
Conversation
…t shutdown, evict LRU - ws-diagnostics.test.ts waits for Bun's server-side close handler before asserting. - socket.test.ts covers an abnormal close while running and quiet shutdown. - ConnectionDiagnostics re-inserts a key on each failure, so eviction drops the least recently used key instead of the oldest inserted. - docs/development.md says websocket.failed also covers server-initiated closes (close_code tells them apart) and that a silent episode's ID and start carry into the next visible failure. Closes #1414
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Peer failure retention server/connection-diagnostics.ts, server/connection-diagnostics.test.ts |
Existing failure keys move to the newest map position. Tests verify that eviction removes the least recently used peer. |
WebSocket close diagnostics docs/development.md, server/core/socket.test.ts, server/ws-diagnostics.test.ts |
Documentation describes failure episode timing and close-code labeling. Tests cover close warnings and wait for server-side close handling before checking diagnostic records. |
Priority:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix · Severity of issue fixed: Low
Suggested reviewers: christi4nity
Merge Risk: 
Minimal · up to 7777f
-
No actionable issue remains identified in these changes; the PR is mergeable after normal checks.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Description check
-
Explanation
The description explains the changes, references the issue, and provides detailed validation results. It uses alternate headings instead of the template headings and does not explicitly state contract-test coverage, but the required change and validation information is substantially present.
Full details: Linked Issues check
-
Explanation
The pull request meets the coding requirements in open issue
#1414.server/ws-diagnostics.test.tswaits for the server-sideclosehandler before assertions.server/core/socket.test.tscovers abnormal close logging during runtime and quiet shutdown.docs/development.mddocuments server-initiatedwebsocket.failedcloses and silent episode timing.ConnectionDiagnostics.failedre-inserts existing keys, and its test verifies least-recently-used eviction.
Full details: Out of Scope Changes check
-
Explanation
The changes stay within issue
#1414. The implementation changes, tests, and documentation directly support the requested WebSocket diagnostics timing, shutdown behavior, event labeling, LRU eviction, and silent-episode semantics. No unrelated change is demonstrated.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 4 files. (1 skipped: 1 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches: 💡 1
-
📝 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.
|
Merge pass review-work report. Overall: PASSED.
Manual QA:
Gate:
All required checks are green, and no review thread is open. |
Closes #1414
What it does
Follow-ups from the review of #1356 (connection diagnostics). Nothing changes in what users see; the diagnostics log gets more accurate and the tests now check what they claim to.
server/ws-diagnostics.test.tswaits for Bun's server-side WebSocketclosehandler before asserting, instead of the client'scloseevent (which sometimes arrives first). The polling loop that followed is gone: the record is written before that handler returns.server/core/socket.test.ts: an abnormal close while running writes onewebsocket.failedrecord, and a close while the server is stopping writes none. Removing!stopped() &&inserver/core/socket.tsnow fails it.docs/development.mdsayswebsocket.failedcovers every close other than 1000/1001, including ones the server starts (device revoke 1008, output stall 4008, a remote PC disconnecting 1012);close_codetells them apart.ConnectionDiagnosticsre-inserts a key on each failure, so the 128-key bound evicts the least recently failed key, not the oldest inserted. New test covers it.docs/development.mdnotes that a silent episode (every failure suppressed) keeps itsepisode_idand start into the next visible failure, sosince_first_failure_msthere can include a healthy gap.Verification
bun run check fastpasses.!stopped() &&fails the new socket test.