You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
MockWebServer can send extra HTTP/2 stream resets before consuming queued responses #9821
I was investigating HttpOverHttp2Test.recoverFromMultipleRefusedStreamsRequiresNewConnection at 67c4f34e7. The test queues two responses that reset the stream with REFUSED_STREAM, followed by a successful response containing "abc".
In Http2SocketHandler.onStream(), MockWebServer reads dispatcher.peek() and applies onRequestStart before calling dispatchBookkeepingRequest(). For CloseStream, this sends the reset before dispatcher.dispatch(request) consumes the queued response.
Since stream handlers run concurrently, a client can receive the reset and retry while the previous handler has not yet consumed its response. The retry can then observe the same queued response.
I reproduced this with a debugger:
Run recoverFromMultipleRefusedStreamsRequiresNewConnection.
Set a breakpoint on requestQueue.add(request) inside dispatchBookkeepingRequest() in MockWebServer.kt.
Set the breakpoint to suspend only the current thread.
Leave the handler suspended so the client can retry.
The client received two refusals on the original connection, opened another connection, and received a third refusal there. The call then failed with StreamResetException: REFUSED_STREAM, even though only two refusals were queued.
I would expect each scripted refusal to be consumed once, with the third attempt receiving "abc".
The breakpoint deliberately forces a delay between sending the reset and consuming the response. I haven’t reproduced this exact failure without the debugger or established whether it explains the Windows CI failure that prompted the investigation.
Environment: Arch Linux x86_64, Java 21, Gradle 9.8.2.
Activity
Amir-Golmoradi commentedon Oct 27, 2026
@JakeWharton , could you take a look at this when you have a chance?
JakeWharton commentedon Oct 27, 2026
There is no need to mention individual maintainers. We see issues automatically. But generally, no, I don't really review too much here anymore.
Amir-Golmoradi commentedon Oct 27, 2026
Noted.