You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cancel non-streaming chat inference when clients disconnect - #1188
Monitor the non-streaming Chat Completions TCP connection during synchronous inference without reading request bytes, and cancel the active request on peer disconnect.
Release request-scoped session and Engine state after cancellation and classify disconnected route telemetry as canceled rather than a successful completion or inference failure. Streaming behavior and other endpoints are unchanged.
Cover buffered-input/keep-alive safety, stop-on-completion, an actual HTTP disconnect with canceled telemetry and a successful follow-up request.
Verification
Built via python sdk_v2/cpp/build.py on Linux.
Focused monitor, HTTP disconnect, and pre-existing streaming-disconnect tests passed.
Normal TCP peer disconnects are in scope; silent network blackholes without FIN/RST require a separately specified request deadline. Windows socket handling is included but was not exercised on a Windows runner.
Watch the non-streaming request's TCP peer without consuming input, cancel the active request when the client closes, and classify the disconnected route as canceled. Exercise the socket monitor and real HTTP inference cleanup, including a successful follow-up request.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 92506982-4b86-4eca-aa81-4f0abfcb5a8a
Read TCP state when a peek finds unread bytes, so a peer FIN cannot be masked by pipelined data. Exercise the Windows socket case and wait for the asynchronous route telemetry action before asserting cancellation.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 92506982-4b86-4eca-aa81-4f0abfcb5a8a
Stop() sets the stop token before guaranteeing one final socket check. A FIN/RST can therefore arrive after the worker's last poll (or before the new thread first runs), then Stop() wakes/joins the worker and returns false; the handler records a successful route even though the peer disconnected during inference. Please synchronize shutdown with a final nonblocking PeerDisconnected check (while retaining the connection/request safely), and add a regression test for disconnect-immediately-before-stop.
Retain the TCP connection through monitor shutdown and perform a final nonblocking peer check after joining its worker, including a regression for an immediate disconnect before Stop. Keep repeated Stop calls from rechecking a completed request.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 92506982-4b86-4eca-aa81-4f0abfcb5a8a
Addressed the new Copilot review finding in 2b47789. Stop() now joins the worker and performs one final nonblocking peer check while the monitor still owns the TCP connection and request; repeated Stop calls do not recheck a completed request. Added an immediate-disconnect-before-Stop regression (and made the Windows buffered-input case exercise immediate Stop). Focused disconnect and existing streaming tests passed in 10 repeated runs.
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
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.
Summary
Verification
python sdk_v2/cpp/build.pyon Linux.Normal TCP peer disconnects are in scope; silent network blackholes without FIN/RST require a separately specified request deadline. Windows socket handling is included but was not exercised on a Windows runner.