Skip to content

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

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

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