Skip to content

Send the CancelRequest before closing the socket - #2

Open
Sanguinor88 wants to merge 1 commit into
hyphatech:mainfrom
OSU-Dev:cancel-before-close
Open

Sanguinor88 wants to merge 1 commit into
hyphatech:mainfrom
OSU-Dev:cancel-before-close

Conversation

@Sanguinor88

Copy link
Copy Markdown

When a statement was given up on (a timeout, a cancellation, or a raise from the caller's callback), stop closed the connection first and only then sent the CancelRequest for it. The server saw the session end before the cancel arrived, and a pooling proxy can drop a cancel for a client session that has already disconnected, so the statement went on running for nobody.

stop now sends the cancel first and closes the connection in a finally, so the connection is closed whatever the cancel does. The cancel opens a connection of its own and reads nothing from this one's stream, which no exchange reads once it is given up on; it keeps its shield and its bound of 5 s or the timeout, so a caller waits no longer than before, and a failed cancel is still ignored. The new case, 54.2.8 a cancel is sent before the connection closes, has a fake server note whether the session is still open when the CancelRequest arrives. The docs now give the order: cancelled, then closed.

When a statement was given up on (a timeout, a cancellation, or a raise
from the caller's callback), stop closed the connection first and only
then sent the CancelRequest for it. The server saw the session end
before the cancel arrived, and a pooling proxy can drop a cancel for a
client session that has already disconnected, so the statement went on
running for nobody.

stop now sends the cancel first and closes the connection in a finally,
so the connection is closed whatever the cancel does. The cancel opens a
connection of its own and reads nothing from this one's stream, which no
exchange reads once it is given up on; it keeps its shield and its bound
of 5 s or the timeout, so a caller waits no longer than before, and a
failed cancel is still ignored. The new case, 54.2.8 a cancel is sent
before the connection closes, has a fake server note whether the session
is still open when the CancelRequest arrives. The docs now give the
order: cancelled, then closed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant