Skip to content

Fix compression dropping gRPC status trailers - #685

Merged
jlizen merged 1 commit into
tower-rs:mainfrom
jlizen:fix/compression-drops-grpc-status
May 22, 2026
Merged

jlizen merged 1 commit into
tower-rs:mainfrom
jlizen:fix/compression-drops-grpc-status

Conversation

@jlizen

@jlizen jlizen commented May 22, 2026

Copy link
Copy Markdown
Member

Closes #546

Motivation

When CompressionLayer is applied to a gRPC (or grpc-web) service, response trailers containing grpc-status and grpc-message can be dropped. The client receives an empty trailers frame and errors with "server closed the stream without sending trailers." This became more impactful after #408 enabled compression for application/grpc-web responses.

Solution

The root cause is a regression in the WrapBody::poll_frame trailer-forwarding logic introduced by #618 . After the compression encoder finishes, the code polls the inner body for remaining frames (trailers). The regression changed this section to only forward frames passing is_trailers(), returning None for any other frame type. This could terminate the body early before trailers were delivered.

The fix simplifies the post-compression section to forward all frames from the inner body unconditionally, matching the original behavior from v0.6.2. This is safe because after the encoder returns EOF, any remaining frames from the inner body are either trailers or should be passed through to the caller regardless.

Added regression tests covering trailer preservation through compression for empty bodies (common gRPC error responses), streamed multi-chunk bodies, and application/grpc-web content type responses.

@jlizen
jlizen merged commit ac7b47c into tower-rs:main May 22, 2026
12 checks passed
seanmonstar added a commit that referenced this pull request Jul 13, 2026
This is a regression introduced in #685. While trailers frames should be
forwarded, they already were. Extra data frames after decompression is complete
is a body error.
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.

Compression drops gRPC status trailers

2 participants