Skip to content

okhttp: Handle zero WINDOW_UPDATE by stream scope - #13068

Open
perepeli wants to merge 1 commit into
grpc:masterfrom
perepeli:fix-okhttp-zero-window-update
Open

perepeli wants to merge 1 commit into
grpc:masterfrom
perepeli:fix-okhttp-zero-window-update

Conversation

@perepeli

Copy link
Copy Markdown
Contributor

A zero-increment WINDOW_UPDATE on a stream is currently handled too early by the OkHttp frame reader. It throws while parsing, which turns the error into a connection-level failure before the transport can tell whether it belongs to the connection or to one stream.

In practice, that means a bad WINDOW_UPDATE for one stream can take down the whole HTTP/2 connection and unrelated RPCs using it.

This changes the handling so the transport gets to make that distinction:

  • stream 0 + zero increment still fails the connection with PROTOCOL_ERROR
  • a non-zero stream + zero increment is handled at stream scope with RST_STREAM(PROTOCOL_ERROR)
  • the client now sends the error code passed to finishStream() instead of always sending CANCEL

Tests cover the parser path and both client/server cases for stream- and connection-scoped zero increments.

No API changes, just narrower failure handling for this edge case.

RFC 9113 section 6.9 requires a WINDOW_UPDATE with a zero increment to be
treated as a PROTOCOL_ERROR. For stream 0 this is a connection error; for
any other stream it is a stream error scoped to that stream only.

The OkHttp frame reader previously rejected the value while parsing,
before either transport's handler had a chance to distinguish those
scopes, so any zero-increment WINDOW_UPDATE tore down the whole
connection regardless of which scope actually applied.

Let the frame reader dispatch the value to the handler instead. The
client handler already contained the stream-vs-connection classification;
wire it up by having finishStream() send the caller-supplied RST_STREAM
error code instead of always sending CANCEL. Add the equivalent
classification to the server handler, which previously had none.

Add regression coverage for parser dispatch and for client/server
stream-vs-connection behavior on both the violating and unaffected paths.

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.

1 participant