Skip to content

fix(gateway): drop WebChat frames for closed sockets - #115

Closed
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/high-severity-issues-9537
Closed

cursor[bot] wants to merge 1 commit into
mainfrom
cursor/high-severity-issues-9537

Conversation

@cursor

@cursor cursor Bot commented Oct 11, 2026

Copy link
Copy Markdown

Bug and impact

WebChat replies for a connection that already closed stayed on the process-wide outgoing queue. ws_dequeue_outgoing only runs for a live socket, so those frames were never removed. After 64 such replies (MAX_QUEUE), ws_send_to failed 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_to enqueued the frame before checking that a socket was registered, and returned success when wsi was NULL. ws_unregister_conn cleared the connection table entry but left that conn_id's frames on the shared list.

Fix

  • On unregister, drop outgoing frames for that conn_id.
  • If no live socket is registered, free the frame and do not enqueue. The return stays 0, matching the existing contract for a well-formed session id with no socket.

Validation

make test_ws then ./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_id that was never registered. Both must leave room for a live client. Existing WebSocket queue tests still pass.

Open in Web聽View Automation聽

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>
@adriannoes

Copy link
Copy Markdown
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.

@adriannoes adriannoes closed this Oct 16, 2026
@adriannoes
adriannoes deleted the cursor/high-severity-issues-9537 branch October 16, 2026 02:56
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.

2 participants