Skip to content

Don't crash when a cancelled app tries to close the stream - #376

Closed
gyanu2507 wants to merge 1 commit into
pgjones:mainfrom
gyanu2507:fix/cancel-send-after-reset
Closed

gyanu2507 wants to merge 1 commit into
pgjones:mainfrom
gyanu2507:fix/cancel-send-after-reset

Conversation

@gyanu2507

@gyanu2507 gyanu2507 commented Sep 18, 2026 •

Copy link
Copy Markdown

Fixes #352.

_handle always await send(None) in finally. After a cancel the h2 connection can already be reset, so that send raises AssertionError: cannot call write() after reset() and hides the CancelledError. Restart then looks like a protocol bug.

On CancelledError, still try to close the ASGI stream, but ignore a send failure. Same change in the trio worker.

_handle always sent None in finally. After a cancel the h2/h11
connection can already be reset, so that send raised and hid
CancelledError.

Fixes pgjones#352
@gyanu2507

Copy link
Copy Markdown
Author

Closing this to narrow my open-source work to fewer projects. Anyone is welcome to pick the change up if it's useful.

@gyanu2507 gyanu2507 closed this Nov 9, 2026
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.

AssertionError: cannot call write() after reset()

1 participant