Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not send RST_STREAM when UnprocessedRequestException is raised #6157

Merged
merged 5 commits into from
Mar 12, 2025

Conversation

minwoox
Copy link
Contributor

@minwoox minwoox commented Mar 12, 2025

Motivation:
When an UnprocessedRequestException is raised, the client should not send an RST_STREAM.

Modifications:

  • Updated the Http2ResponseDecoder to avoid sending RST_STREAM when UnprocessedRequestException occurs.

Result:

  • The client does not send an RST_STREAM when an UnprocessedRequestException is raised.

Motivation:
When an `UnprocessedRequestException` is raised, the client should not send an `RST_STREAM`.

Modifications:
- Updated the `Http2ResponseDecoder` to avoid sending `RST_STREAM` when `UnprocessedRequestException` occurs.

Result:
- The client does not send an `RST_STREAM` when an `UnprocessedRequestException` is raised.
@minwoox minwoox added the defect label Mar 12, 2025
@minwoox minwoox added this to the 1.32.1 milestone Mar 12, 2025
@@ -92,6 +92,9 @@ private void onWrapperCompleted(HttpResponseWrapper resWrapper, int id, @Nullabl
resWrapper.onSubscriptionCancelled(cause);

if (cause != null) {
if (cause instanceof UnprocessedRequestException) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We may not need to send RST_STREAM when the stream was closed or a RST_STREAM was received before. I was wondering if our logic already handles the cases.

if (res.isOpen()) {
if (!goAwayHandler.receivedGoAway()) {
res.close(newClosedStreamException(channel()));
return;
}
final int lastStreamId = conn.local().lastStreamKnownByPeer();
if (stream.id() > lastStreamId) {
res.close(UnprocessedRequestException.of(GoAwayReceivedException.get()));
} else {
res.close(newClosedStreamException(channel()));
}
}

Copy link
Contributor Author

@minwoox minwoox Mar 12, 2025

Choose a reason for hiding this comment

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

I think Netty handles those cases:
https://github.com/netty/netty/blob/4.1/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2ConnectionHandler.java#L808-L810
The problem that I fixed is that it tries to send RST_STREAM even though the stream was removed. Let me also add that condition to prevent the situation.

Copy link
Contributor

Choose a reason for hiding this comment

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

Netty seems to send another RST_STREAM by encoder.writeRstStream() when the client receives an RST_STREAM or the connection is closed.

My suggestion is:

if (cause instanceof UnprocessedRequestException || 
    cause instanceof ClosedStreamException) {
   return;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks addressed. 👍

Copy link
Contributor

@ikhoon ikhoon left a comment

Choose a reason for hiding this comment

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

Thanks!

@minwoox minwoox merged commit e0f4682 into line:main Mar 12, 2025
13 of 14 checks passed
@minwoox minwoox deleted the HeaderListSizeException branch March 12, 2025 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants