fix: avoid crashes when resetting retired QUIC streams by mvanhorn · Pull Request #8496 · mitmproxy/mitmproxy · GitHub
Skip to content

fix: avoid crashes when resetting retired QUIC streams - #8496

Open
mvanhorn wants to merge 1 commit into
mitmproxy:mainfrom
mvanhorn:fix/7408-quic-retired-stream-reset
Open

mvanhorn wants to merge 1 commit into
mitmproxy:mainfrom
mvanhorn:fix/7408-quic-retired-stream-reset

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Oct 20, 2026 •

Copy link
Copy Markdown

Description

Fixes #7408.

When a ResetQuicStream command arrives for a stream that aioquic has already retired, QuicLayer._handle_command calls _get_or_create_stream_for_send. For a peer-initiated stream that raises ValueError: Cannot send data on unknown peer-initiated stream, which is the crash in the issue. For a locally initiated stream it quietly recreates the stream instead.

The fix skips the reset when the stream id is already in self.quic._streams_finished. A finished stream has nothing left to reset, so dropping the late command is safe. This reads a private aioquic attribute, as the code right below it already does with _get_or_create_stream_for_send and _reset_error_code.

test_stream_reset_retired retires a stream in each direction, for both client and server, and then sends a reset. Without the fix all four cases fail (the ValueError, or the stream coming back); with it they pass. The full test/mitmproxy/proxy suite, ruff and mypy pass locally.

Checklist

  • I have updated tests where applicable.
  • I have added an entry to the CHANGELOG.

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.

mitmproxy has crashed!

1 participant