Skip to content

QWP sender close() skips WebSocket CLOSE when the I/O thread is descheduled >100 ms #117

Open

Description

@jerrinot

CursorWebSocketSendLoop.close() waits 100 ms (DEFAULT_CLOSE_GRACEFUL_STOP_MILLIS) for the I/O thread to exit, then calls closeTraffic() (:1380). On a CPU-starved host a healthy, idle I/O thread can miss that window, so the socket is shut down before its exit path (:2741) sends the WebSocket CLOSE and TLS close_notify. The server logs detected EOF instead of a clean close. No data loss: drainOnClose() completes first.

Seen once in CI on a 2-vCPU Windows agent; the server log shows a 118 ms scheduling gap right before the EOF and no CLOSE received.

Fix: call closeTraffic() only when the I/O thread is actually blocked in sendBinary/sendPing (volatile flag around those calls); otherwise keep waiting on shutdownLatch up to the existing backstop.

Line refs: 1.3.11, unchanged on main. Window introduced in a7e7db3 (#104).

Activity

  1. added
    bug
    on Oct 27, 2026
  2. changed the title [-]QWP sender close() drops the connection without a WebSocket CLOSE when the I/O thread is descheduled for more than 100 ms[/-] [+]QWP sender close() skips WebSocket CLOSE when the I/O thread is descheduled >100 ms[/+] on Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions