fix(backend): break outer loop on client write failure for accesses/TPS - #116
Conversation
|
@ayushsingh82 is attempting to deploy a commit to the MF Flagship Team on Vercel. A member of the Team first needs to authorize it. |
|
Gentle follow-up here — mergeable, small fix to break the outer loop on client write failure for accesses/TPS so the run doesn't spin after the client goes away. Let me know if you'd like anything changed. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@ayushsingh82 Can you rebase on top of the latest changes on main? |
881b23e to
b22223b
Compare
|
@iamvukasin done, rebased on the latest |
|
@ayushsingh82 Can you also use verified signatures for commits? |
Motivation: In client_write_task, a failed send_message() for the accesses_buf or tps_buf messages only broke the inner `for` loop over the buffered items, not the outer task loop. This is inconsistent with the events_buf send right above it, which correctly breaks the outer loop on failure. A send failure here means the client is gone (write error on the WebSocket, e.g. broken pipe after disconnect). Once that happens, the task should stop - but with the inner break, it fell through to the next iteration of the outer loop and kept trying (and failing) to serve the same dead connection indefinitely instead of exiting, unlike every other failure path in this function. Modifications: Label the outer loop and change the two nested breaks to `break 'outer'` so a write failure on any buffer (events, accesses, or TPS) terminates the task the same way. Result: client_write_task now exits promptly on any write failure, regardless of which buffer triggered it, matching its behavior for the other error paths in the same function (broadcast receiver errors, events send failures).
b22223b to
e0031ad
Compare
|
@iamvukasin done. Force-pushed with an SSH-signed commit (now |
|
Thank you for your contribution. |
Summary
client_write_taskinbackend/src/lib/server.rssends three kinds of buffered messages to a WebSocket client each iteration:events_buf,accesses_buf, andtps_buf. Whensend_message()fails forevents_buf, the code correctlybreaks the outerloop, terminating the task for that (now-dead) connection.But for
accesses_bufandtps_buf, the send happens inside aforloop over the buffered items, and thebreakon failure only exits that innerforloop — not the outer task loop:A
send_messagefailure here means the client's WebSocket write is broken (e.g. disconnected). Once that happens, the task should exit — same intent as theevents_bufpath right above it — but instead it falls through and keeps looping, repeatedly trying (and failing) to serve a dead connection instead of terminating.Changes
loopas'outerand change the two nestedbreaks (in theaccesses_bufandtps_bufsend loops) tobreak 'outer, so a write failure on any buffer terminates the task consistently.breaks elsewhere in the function (broadcast receiver error, events send failure) are unaffected since they weren't nested in aforloop to begin with.Test plan
breakinside aforinside alooponly exits thefor) and confirmed the labeled-loop fix resolves it.cargo fmt --checkpasses on the crate.cargo check/cargo clippy/cargo test— could not run locally on macOS;monad-event-ring's build script requirescmakeand Linuxhugetlbfsheaders not available in this environment (same constraint noted in fix(backend): prevent panic when txn_idx exceeds fixed buffer size #115). Deferred to CI.Greptile Summary
This PR makes WebSocket client write failures terminate the client task consistently.
Confidence Score: 5/5
The PR appears safe to merge.
No blocking failure remains.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Client write loop] --> B{Buffered message available?} B -->|Events| C[Send event message] B -->|Accesses| D[Send access message] B -->|TPS| E[Send TPS message] C --> F{Send succeeded?} D --> F E --> F F -->|Yes| A F -->|No| G[Exit outer client task loop]Reviews (3): Last reviewed commit: "fix(backend): break outer loop on client..." | Re-trigger Greptile