Skip to content

server: Preserve the RPC status when a compressed RPC ends before response compressor setup. - #9314

Open
RayanAlsalemi wants to merge 2 commits into
grpc:masterfrom
RayanAlsalemi:fix/send-compressor-cancellation-status
Open

server: Preserve the RPC status when a compressed RPC ends before response compressor setup.#9314
RayanAlsalemi wants to merge 2 commits into
grpc:masterfrom
RayanAlsalemi:fix/send-compressor-cancellation-status

Conversation

@RayanAlsalemi

@RayanAlsalemi RayanAlsalemi commented Aug 13, 2026

Copy link
Copy Markdown

Fixes #9313

A compressed RPC can end after the server receives the request headers but before grpc-go sets the response compressor. When that happens, SetSendCompress returns a "headers sent or stream done" error and the server stats report Internal even if the stream was canceled or its deadline expired.

This change records the first status used to close the transport stream. If SetSendCompress runs after the stream is done, it returns that status. If the headers were already sent, or there is no recorded close status, it keeps the existing error.

RELEASE NOTES:

  • server: Preserve the RPC status when a compressed RPC ends before response compressor setup.

@linux-foundation-easycla

linux-foundation-easycla Bot commented Aug 13, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: RayanAlsalemi / name: Rayan Alsalemi (fe54e06)

@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.12%. Comparing base (ec03539) to head (3815870).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
internal/transport/http2_server.go 80.00% 2 Missing ⚠️
internal/transport/http_util.go 60.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9314      +/-   ##
==========================================
- Coverage   83.22%   83.12%   -0.11%     
==========================================
  Files         423      423              
  Lines       35139    35251     +112     
==========================================
+ Hits        29244    29301      +57     
- Misses       4400     4437      +37     
- Partials     1495     1513      +18     
Files with missing lines Coverage Δ
internal/transport/server_stream.go 96.92% <100.00%> (+0.31%) ⬆️
server.go 83.70% <100.00%> (+0.27%) ⬆️
internal/transport/http2_server.go 90.33% <80.00%> (-0.33%) ⬇️
internal/transport/http_util.go 96.68% <60.00%> (-0.62%) ⬇️

... and 32 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@RayanAlsalemi RayanAlsalemi changed the title server: preserve context status on send compressor setup failure server: preserve context status code on send compressor setup failure Aug 13, 2026
@RayanAlsalemi
RayanAlsalemi force-pushed the fix/send-compressor-cancellation-status branch from fe54e06 to 259972b Compare August 13, 2026 07:59
@easwars
easwars requested a review from mbissa August 13, 2026 19:36
@easwars easwars added Type: Bug Area: RPC Features Includes Compression, Encoding, Attributes/Metadata, Interceptors. labels Aug 13, 2026
@easwars easwars added this to the 1.84 Release milestone Aug 13, 2026
@easwars

easwars commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

@mbissa : I've categorized this PR with a "bug" label. But we should check the behavior of the other language implementations before proceeding with this.

@RayanAlsalemi

RayanAlsalemi commented Aug 15, 2026

Copy link
Copy Markdown
Author

I've updated the PR so the transport records the first close status. If compressor setup runs after the stream is already done, it can return that status directly instead of checking ctx.Err() afterward.

@RayanAlsalemi RayanAlsalemi changed the title server: preserve context status code on send compressor setup failure server: Preserve the RPC status when a compressed RPC ends before response compressor setup. Aug 15, 2026
@RayanAlsalemi
RayanAlsalemi force-pushed the fix/send-compressor-cancellation-status branch from 3300378 to 3815870 Compare August 15, 2026 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: RPC Features Includes Compression, Encoding, Attributes/Metadata, Interceptors. Type: Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

server: cancellation before send compressor setup is reported as Internal

3 participants