Skip to content

gRPC-Web: Fix failing HTTP/2 requests on some browsers due to empty trailers - #12178

Merged
dio merged 41 commits into
envoyproxy:masterfrom
dio:issue-10514-grpc-web-webkit
Aug 5, 2020
Merged

dio merged 41 commits into
envoyproxy:masterfrom
dio:issue-10514-grpc-web-webkit

Conversation

@dio

@dio dio commented Jul 20, 2020 •

Copy link
Copy Markdown
Member

Commit Message: This adds envoy.reloadable_features.skip_encoding_empty_trailers runtime feature flag (enabled by default) to skip encoding empty trailers in H2 codec. This behavior can be reverted temporarily by setting runtime feature envoy.reloadable_features.skip_encoding_empty_trailers to false.

Before this commit, seeing empty trailers of gRPC-Web filter response:

[  5.036] recv DATA frame <length=28, flags=0x00, stream_id=13>
[  5.040] recv DATA frame <length=52, flags=0x00, stream_id=13>
[  5.053] recv HEADERS frame <length=0, flags=0x05, stream_id=13>
          ; END_STREAM | END_HEADERS

After:

[  5.036] recv DATA frame <length=28, flags=0x00, stream_id=13>
[  5.040] recv DATA frame <length=52, flags=0x00, stream_id=13>
[  5.052] recv DATA frame <length=0, flags=0x01, stream_id=13>
          ; END_STREAM

Signed-off-by: Dhi Aurrahman [email protected]

Additional Description: I have a reproducer here: https://github.com/dio/grpc-web-hello, and this patch is confirmed to work: #10514 (comment). For WebKit, the issue is logged here: https://bugs.webkit.org/show_bug.cgi?id=210108. The issue is also observed in Internet Explorer 11 and Edge on various patch versions of Windows 10 (pre-Chromium).

Risk Level: Low
Testing: Updated
Docs Changes: N/A.
Release Notes: Added
Fixes #10514

@dio dio changed the title grpc-web: Fix failing HTTP/2 requests on WebKit-based browser grpc-web: Fix failing HTTP/2 requests on some browsers Jul 20, 2020
dio added 3 commits July 21, 2020 06:57
Signed-off-by: Dhi Aurrahman <[email protected]>
Signed-off-by: Dhi Aurrahman <[email protected]>
Signed-off-by: Dhi Aurrahman <[email protected]>
@dio dio changed the title grpc-web: Fix failing HTTP/2 requests on some browsers WIP: grpc-web: Fix failing HTTP/2 requests on some browsers Jul 22, 2020
@dio
dio marked this pull request as draft July 22, 2020 03:56
dio added 4 commits July 22, 2020 04:28
Signed-off-by: Dhi Aurrahman <[email protected]>
Signed-off-by: Dhi Aurrahman <[email protected]>
@dio dio changed the title WIP: grpc-web: Fix failing HTTP/2 requests on some browsers WIP: Fix failing HTTP/2 requests on some browsers due to empty trailers Jul 22, 2020
Signed-off-by: Dhi Aurrahman <[email protected]>
@dio

dio commented Jul 22, 2020

Copy link
Copy Markdown
Member Author

Before working on this further. I would like to validate the direction of this PR. To give a scoped context: gPRC-Web Filter, mandated by spec to embed the trailers in the body, hence it clears the trailers after copying it to the body. Since we always encode empty trailers, this introduces an issue for Safari (as reported here https://bugs.webkit.org/show_bug.cgi?id=210108 ) and other browsers (i.e. IE11 pre-Chromium era #10514) when the downstream is HTTP/2.

@lizan @alyssawilk could you give your advice here? I'm not sure if HCM level is OK for this since this, I think, can be done in our H2 codec as well (from my limited knowledge of understanding code seems like the example from nghttp2 is also skipping submitting trailers when it is empty: https://github.com/nghttp2/nghttp2/blob/a3a034813b86f7413b745ce9e416bc9f8e7fd053/src/shrpx_http2_downstream_connection.cc#L206). Or probably there is a better solution for this.

Thank you 🙏🏽.

Comment thread source/common/http/conn_manager_impl.cc Resolved
@dio
dio marked this pull request as ready for review July 24, 2020 08:25
@dio dio changed the title WIP: Fix failing HTTP/2 requests on some browsers due to empty trailers http: Fix failing HTTP/2 requests on some browsers due to empty trailers Jul 24, 2020

@mattklein123 mattklein123 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks LGTM modulo small comment and sorting out clang-tidy which seems like it almost about to be fixed.

/wait

void ConnectionImpl::StreamImpl::submitTrailers(const HeaderMap& trailers) {
const bool skip_encoding_empty_trailers =
trailers.empty() && parent_.skip_encoding_empty_trailers_;
if (skip_encoding_empty_trailers) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can you ASSERT(local_end_stream_) above this line? I think it should always be true?

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 in 3f2c2d8.

mattklein123
mattklein123 previously approved these changes Aug 3, 2020

@mattklein123 mattklein123 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Awesome, thanks!

@dio

dio commented Aug 4, 2020

Copy link
Copy Markdown
Member Author

/retest

@repokitteh-read-only

Copy link
Copy Markdown

🔨 rebuilding ci/circleci: go_control_plane_mirror (failed build)

🐱

Caused by: a #12178 (comment) was created by @dio.

see: more, trace.

@dio

dio commented Aug 4, 2020

Copy link
Copy Markdown
Member Author

Thanks to @lizan clang-tidy issue for codec_impl.h is fixed.

@mattklein123

Copy link
Copy Markdown
Member

LGTM can you merge main?

/wait

@dio

dio commented Aug 4, 2020

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@dio
dio merged commit 7d03b62 into envoyproxy:master Aug 5, 2020
@dio
dio deleted the issue-10514-grpc-web-webkit branch August 5, 2020 02:40
chaoqin-li1123 pushed a commit to chaoqin-li1123/envoy that referenced this pull request Aug 7, 2020
…railers (envoyproxy#12178)

This adds `envoy.reloadable_features.skip_encoding_empty_trailers` runtime feature flag (enabled by default) to skip encoding empty trailers in H2 codec. This behavior can be reverted temporarily by setting runtime feature `envoy.reloadable_features.skip_encoding_empty_trailers` to false.

Before this commit, seeing empty trailers of gRPC-Web filter response, codec submits:

```
[  5.036] recv DATA frame <length=28, flags=0x00, stream_id=13>
[  5.040] recv DATA frame <length=52, flags=0x00, stream_id=13>
[  5.053] recv HEADERS frame <length=0, flags=0x05, stream_id=13>
          ; END_STREAM | END_HEADERS
```

After:

```
[  5.036] recv DATA frame <length=28, flags=0x00, stream_id=13>
[  5.040] recv DATA frame <length=52, flags=0x00, stream_id=13>
[  5.052] recv DATA frame <length=0, flags=0x01, stream_id=13>
          ; END_STREAM
```

Risk Level: Low
Testing: Unit, integration tests.
Docs Changes: N/A.
Release Notes: Added
Fixes envoyproxy#10514

Signed-off-by: Dhi Aurrahman <[email protected]>
chaoqin-li1123 pushed a commit to chaoqin-li1123/envoy that referenced this pull request Aug 7, 2020
…railers (envoyproxy#12178)

This adds `envoy.reloadable_features.skip_encoding_empty_trailers` runtime feature flag (enabled by default) to skip encoding empty trailers in H2 codec. This behavior can be reverted temporarily by setting runtime feature `envoy.reloadable_features.skip_encoding_empty_trailers` to false.

Before this commit, seeing empty trailers of gRPC-Web filter response, codec submits:

```
[  5.036] recv DATA frame <length=28, flags=0x00, stream_id=13>
[  5.040] recv DATA frame <length=52, flags=0x00, stream_id=13>
[  5.053] recv HEADERS frame <length=0, flags=0x05, stream_id=13>
          ; END_STREAM | END_HEADERS
```

After:

```
[  5.036] recv DATA frame <length=28, flags=0x00, stream_id=13>
[  5.040] recv DATA frame <length=52, flags=0x00, stream_id=13>
[  5.052] recv DATA frame <length=0, flags=0x01, stream_id=13>
          ; END_STREAM
```

Risk Level: Low
Testing: Unit, integration tests.
Docs Changes: N/A.
Release Notes: Added
Fixes envoyproxy#10514

Signed-off-by: Dhi Aurrahman <[email protected]>
Signed-off-by: chaoqinli <[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-Web requests on Safari fail when using Envoy 1.13

8 participants