Uh oh!
There was an error while loading. Please reload this page.
fix(h2_connection_reset): add stream reset when client cancel the req… - #944
fix(h2_connection_reset): add stream reset when client cancel the req…#944MarkLux wants to merge 7 commits into
Conversation
7455935 to
9924db4CompareUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Thanks, seems like a good start. Make sure to run scripts/unasync.py to also apply the changes to the httpcore/_sync/http2.py module.
https://github.com/encode/httpcore/actions/runs/10464774808/job/28978912844#step:5:26
(Related... maybe we could change the build logs when unasync --check fails, so that there's clearer feedback to the developer.)
46031e9 to
5997901CompareUh oh!
There was an error while loading. Please reload this page.
af2e7e4 to
c061e4fComparebd4f039 to
18422ffCompareMarkLux
commented
Sep 11, 2024
sorry to bother but we are really in a hurry to fix this one, could you have a review again? @tomchristie |
MarkLux
commented
Oct 12, 2024
approved by langchain community now, shall we have any further progress on this one? @tomchristie |
| # need send cancel frame when the exception is not from remote peer. | ||
| if not isinstance(exc, RemoteProtocolError): |
There was a problem hiding this comment.
need send cancel frame when the exception is not from remote peer.
It's not obvious to me that not isinstance(exc, RemoteProtocolError) is correct/sufficient here.
Should this instead be something like just wrapping the yield?...
try:
yieldchunkexceptExceptionasexc:
self._connection._reset_steam(
stream_id=self._stream_id,
error_code=h2.settings.ErrorCodes.CANCEL,
)
raiseexcThere was a problem hiding this comment.
BaseException covers asyncio.CancelledError as well, which should also reset the stream.
lovelydinosaur
commented
Oct 29, 2024
Thanks @MarkLux - apologies for the delay it's a bit of a complex one to review. Thoughts on my review comment? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
mabrowning
commented
Jan 9, 2026
This PR or something like it is still needed. Even with the latest version of httpcore, if the client closes the response before the server is done, the client does not send any |
| def _reset_steam(self, stream_id: int, error_code: int) -> None: | ||
| self._h2_state.reset_stream(stream_id=stream_id, error_code=error_code) |
There was a problem hiding this comment.
After updating the local h2_state, we should write the updated bytes on the wire, otherwise its reliant on some (possibly much) later write (like initiating a new request or a keep-alive frame) sending the reset.
Summary
add the missing connection reset of h2 connection when client cancel the request.
fix#943
in discussion with #941