Repository navigation
fix(gateway): drop WebChat frames for closed sockets - #115
Closed
cursor[bot] wants to merge 1 commit into
Closed
cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
Replies for a disconnected webchat conn_id stayed on the shared outgoing queue. After 64 of those, every live client failed to send until restart. Discard frames on unregister, and do not enqueue when no socket is registered. Co-authored-by: esadrianno <esadrianno@gmail.com>
Collaborator
|
Superseded by #119: consolidated into the operator-authored branch fix/gateway-ws-frames (same fix, re-validated with make test_ws, CI=true make test, make static). Closing in favor of the consolidation. |
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.
Bug and impact
WebChat replies for a connection that already closed stayed on the process-wide outgoing queue.
ws_dequeue_outgoingonly runs for a live socket, so those frames were never removed. After 64 such replies (MAX_QUEUE),ws_send_tofailed for every client, including ones still connected. Dashboard WebChat then delivered nothing until the process restarted.Concrete trigger: a client sends a prompt and disconnects (refresh, dropped network) before the reply is written. Each lost reply occupies one queue slot forever. A long-running edge process hits the cap through ordinary reconnects.
Root cause
ws_send_toenqueued the frame before checking that a socket was registered, and returned success whenwsiwas NULL.ws_unregister_conncleared the connection table entry but left thatconn_id's frames on the shared list.Fix
conn_id.Validation
make test_wsthen./build/test_ws.New cases cover a frame queued before close (spliced out of the middle of the list, with a sibling connection left intact) and 128 sends to a
conn_idthat was never registered. Both must leave room for a live client. Existing WebSocket queue tests still pass.