Skip to content

Return cleanly on WS upgrade handshake WriteFailed instead of logging unhandled exception#126

Merged
kwsantiago merged 1 commit into
mainfrom
fix/ws-upgrade-writefailed
Jun 29, 2026
Merged

Return cleanly on WS upgrade handshake WriteFailed instead of logging unhandled exception#126
kwsantiago merged 1 commit into
mainfrom
fix/ws-upgrade-writefailed

Conversation

@wksantiago

@wksantiago wksantiago commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Closes #125

Summary by CodeRabbit

  • Bug Fixes
    • Improved WebSocket connection handling so client disconnects during the upgrade handshake are handled gracefully without triggering a generic error path.
    • Preserved existing responses for other upgrade failures, including rate-limit and service-unavailable cases.

@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b2042179-0671-4ca4-a932-bd28ddc2cd7a

📥 Commits

Reviewing files that changed from the base of the PR and between bbea8bd and 520c3bd.

📒 Files selected for processing (1)
  • src/server.zig

Walkthrough

In App.getRoot, the httpz.upgradeWebsocket error switch gains an error.WriteFailed case that returns immediately, handling the case where a client disconnects during the WebSocket 101 upgrade handshake instead of routing to the generic error path.

WebSocket Upgrade Error Handling

Layer / File(s) Summary
Catch WriteFailed in upgradeWebsocket error switch
src/server.zig
Adds error.WriteFailed => return to the upgrade error switch so client disconnects mid-handshake return silently rather than hitting the 429/503 fallback.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

  • privkeyio/wisp#117: Modifies the same httpz.upgradeWebsocket error handling block in App.getRoot to handle 429/503 cases for connection-limit errors.
  • privkeyio/wisp#122: Applies the same error.WriteFailed => return pattern in src/server.zig for NIP-11 mid-write client disconnects.

Suggested reviewers

  • kwsantiago

Poem

A client knocked, then slipped away mid-shake,
No error logged, no fuss left in its wake.
One line of Zig, a silent early return,
The rabbit hops past errors of no concern.
🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the WebSocket upgrade handshake WriteFailed handling change.
Linked Issues check ✅ Passed The change handles WriteFailed from WebSocket upgrade handshakes cleanly, matching issue #125's expected disconnect behavior.
Out of Scope Changes check ✅ Passed Only the handshake WriteFailed handling was changed; no unrelated code paths appear introduced.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ws-upgrade-writefailed

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@wksantiago wksantiago self-assigned this Jun 29, 2026
@wksantiago wksantiago requested a review from kwsantiago June 29, 2026 18:51
@kwsantiago kwsantiago merged commit f8f45b3 into main Jun 29, 2026
4 checks passed
@kwsantiago kwsantiago deleted the fix/ws-upgrade-writefailed branch June 29, 2026 19:03
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.

WS upgrade handshake WriteFailed logged as unhandled exception when client disconnects mid-handshake

2 participants