Repository navigation
websocket: report unclean peer closes and keep the 1011 behind an unread overload - #90
Merged
Merged
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 29 minutes. View limit details
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. |
Member
Author
|
Security review record (head
|
- A peer close our side could not answer (poisoned writer) now reports wasClean: false with the peer's code and reason, like the 1011/1009 application closes; echo_websocket_close reports delivery and the worker path marks a failed reply unclean. - Terminal arbitration also reads the outbound budget's trip state, so an Overload marker still unread when the peer close wins still ends the pipe loudly with 1011. - Tests: ScriptedStream helper plus fail-before tests for both edges; shutdown_during_parked_send_ends_pump now expects the unclean peer close (its old expectation was the reported bug).
ryuzdev
force-pushed
the
cello/ws-close-reporting
branch
from
November 20, 2026 09:18
e4392b8 to
671c18b
Compare
Member
Author
|
This is a pure rebase onto |
This was referenced Nov 20, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ws close reporting edges
Closes two deferred CodeRabbit round-3 findings from #83
(
PRRT_...fRiC,PRRT_...fRiV) in the WebSocket pump(
crates/cello/main/websocket.rs).(a) Peer close + poisoned writer reported
wasClean: trueIf our side could not complete the closing handshake on the wire — the
writer was poisoned mid-frame (a timed-out parked send) so no further frame
may follow — the cell still learned the peer's close as clean. The cell now
sees
wasClean: falsewith the peer's code and reason, matching theexisting 1011/1009 application-close convention and what workerd reports
(the abnormal end the peer observes, not the clean frame it sent).
pump_cell_socketdowngrades a Peer close to unclean when the writer ispoisoned at return. This runs before the return so both callers report it:
the cell path dispatches the close before its echo, the worker path echoes
before it reports.
echo_websocket_closenow reports whether the reply crossed (it uses theframe write itself —
write_ws_outreads back false for Close by design),and
worker_websocket_taskmarks the close unclean when the reply isskipped or fails on a live writer.
shutdown_during_parked_send_ends_pumpencoded the bug (it is thefRiC scenario verbatim); it now expects the unclean Peer close. Its
"shutdown ends the pump" invariant is unchanged.
(b) Unread
Overloadmarker lost to a winning peer closeWhen the outbound direction tripped its budget, the marker queues behind
admitted data; if the peer's close ends the read first, the shutdown can
retire the write direction with the marker still unread, and the pump kept
the peer's clean close and skipped the 1011. Terminal arbitration now reads
the direction's trip state, not only the forwarder's
OverLimitoutcome —a tripped budget means the marker was queued — so the loud 1011 still wins
and the peer's clean close survives only when neither direction tripped
(new
WsPipeBudget::is_tripped()). Wire behavior is unchanged: the 1011attempt still runs only at a frame boundary under the close bound.
Notes
writer-idleness tracking, and a wall-clock wait would poison live peers
parked behind a slow data write. Not trivially safe.
the cell path dispatches before the echo, so only the poisoned-at-return
case — the deterministic one — downgrades there. The worker path covers
the echo-timeout case via the return value.
Tests
peer_close_with_poisoned_writer_reports_uncleanandunread_overload_marker_still_wins_over_peer_close(gated writes +duplex-fed peer close; sequenced, no sleeps). Both fail before the fix
(
(1000, "bye", true)kept) and pass after.poisoned_writer_skips_echonow also asserts the echo's delivery report.cargo clippy --profile release --locked --all-targets -- -D warningsclean; fullcargo test --profile release --locked --no-fail-fastpasses;ws_close_conformance,ws_loader_upgrade_conformance,do_later_ws_conformance5x each andoverloaded_pipe_closes_with_101110x pass.