Skip to content

upstream: correctly handle h2 and h3 stream resets with no error - #44749

Merged
ggreenway merged 10 commits into
envoyproxy:mainfrom
ggreenway:h2-rst-noerror
May 18, 2026
Merged

ggreenway merged 10 commits into
envoyproxy:mainfrom
ggreenway:h2-rst-noerror

Conversation

@ggreenway

Copy link
Copy Markdown
Member

Fixed a bug where an upstream HTTP/2 or HTTP/3
RST_STREAM(NO_ERROR) received after a complete response would cause the response to be discarded and replaced with an error. This behavior is common with some gRPC clients and servers, but is often intermittent.

Claude code helped write PR

Risk Level: High
Testing: added new tests
Docs Changes: not needed
Release Notes: added
Runtime guard: envoy.reloadable_features.http_preserve_rst_no_error
Fixes #38206

Fixed a bug where an upstream HTTP/2 or HTTP/3
``RST_STREAM(NO_ERROR)`` received after a complete response would
cause the response to be discarded and replaced with an error. This
behavior is common with some gRPC clients and servers, but is often
intermittent.

Fixes envoyproxy#38206

Signed-off-by: Greg Greenway <[email protected]>
@repokitteh-read-only

Copy link
Copy Markdown

CC @envoyproxy/runtime-guard-changes: FYI only for changes made to (source/common/runtime/runtime_features.cc).

🐱

Caused by: #44749 was opened by ggreenway.

see: more, trace.

@ggreenway

Copy link
Copy Markdown
Member Author

The specific way I saw this happen is when the client for whatever reason does not send end_stream in the same frame as the end of the data or trailers, in a grpc request. The default golang grpc server code reads the entire protobuf payload and calls the registered handler. If the response is fully sent before the client end_stream arrives, golang grpc also sends RST_STREAM(NO_ERROR), which is allowed by the RFC. Envoy sees a reset, and does not finish sending any buffered response to the client.

This PR fixes that behavior, so that envoy does not treat that situation as an error and cancel the response.

Signed-off-by: Greg Greenway <[email protected]>
@ggreenway

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request fixes a bug where an upstream HTTP/2 or HTTP/3 RST_STREAM(NO_ERROR) received after a complete response would cause the response to be discarded and replaced with an error. It introduces a new StreamResetReason::RemoteResetNoError to handle these non-error resets gracefully, ensuring that complete responses—including those with buffered trailers—are preserved and forwarded to the client. This behavior is controlled by the envoy.reloadable_features.http_preserve_rst_no_error runtime flag. Feedback was provided regarding a potential request hang in the router filter if a RemoteResetNoError occurs before the downstream response has been initiated.

Comment thread source/common/router/router.cc Resolved
@ggreenway

Copy link
Copy Markdown
Member Author

/retest

KBaichoo
KBaichoo previously approved these changes May 1, 2026

@KBaichoo KBaichoo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

Comment thread changelogs/current.yaml
response would cause the response to be discarded and replaced with an error. This behavior is
common with some gRPC clients and servers, but is often intermittent. This behavior can be
temporarily reverted by setting the runtime flag
``envoy.reloadable_features.http_preserve_rst_no_error`` to ``false``.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider documenting that these RSTs will not trigger:

  • upstream_rq_rx_reset inc, UpstreamRemoteReset won't be set for these cases.

As it could be confusing to see the RST on the wire but no RST here

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point. Do you agree that we shouldn't set those? I think most/all people see that counter and flag is indications of an error, and this is not an error, so my thinking was to not do that. But it is a reset, and those things are all named "reset".

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you agree that we shouldn't set those? I think most/all people see that counter and flag is indications of an error, and this is not an error, so my thinking was to not do that.

Yes I almost exclusively have used it for this and I suspect a lot of other folks might as well given we've had this non-compliance with the spec for a long time.

I don't like the idea of having this not leaving a signal though. WDYT of having a upstream_rq_no_error_rx_reset stat for the upstream metric as a middle ground?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a metric and documented all this

Wrong PR

This reverts commit ca5dc2a.

Signed-off-by: Greg Greenway <[email protected]>
@ggreenway

Copy link
Copy Markdown
Member Author

/retest

@KBaichoo KBaichoo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@ggreenway
ggreenway merged commit 839f03a into envoyproxy:main May 18, 2026
29 checks passed
alrzazz pushed a commit to alrzazz/envoy that referenced this pull request May 20, 2026
…oyproxy#44749)

Fixed a bug where an upstream HTTP/2 or HTTP/3
``RST_STREAM(NO_ERROR)`` received after a complete response would cause
the response to be discarded and replaced with an error. This behavior
is common with some gRPC clients and servers, but is often intermittent.

Runtime guard: envoy.reloadable_features.http_preserve_rst_no_error
Fixes envoyproxy#38206

Signed-off-by: Greg Greenway <[email protected]>
Signed-off-by: Alireza <[email protected]>
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.

gRPC server issues with envoy proxy on RST_STREAM

3 participants