Fix/grpc empty data#10191
Draft
CurryYangxx wants to merge 2 commits into
Draft
Conversation
A gRPC response whose fields are all defaults (e.g. an empty `repeated` field) serializes to a zero-length message. Some servers still set the compressed flag on that frame and advertise `grpc-encoding: gzip`, so the client receives [compressed=1][length=0]. grpc-js then fed the empty payload to zlib, which throws "unexpected end of file" and surfaced in the UI as `13 INTERNAL: Failed to decompress gzip-encoded message`. Patch @grpc/grpc-js so CompressionHandler.readMessage short-circuits a zero-length payload (which unambiguously decodes to an empty message) instead of attempting decompression. Add a regression test that feeds a gzip-flagged zero-length frame through CompressionFilter. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
✅ Circular References ReportGenerated at: 2026-06-30T10:36:59.006Z Summary
Click to view all circular references in PR (9)Click to view all circular references in base branch (9)Analysis✅ No Change: This PR does not introduce or remove any circular references. This report was generated automatically by comparing against the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & Why
Fixes #8659. A gRPC response with all-default fields (e.g. an empty
repeatedfield) serializes to a 0-byte message. Some servers still flag that frame as compressed and sendgrpc-encoding: gzip, so the client receives[compressed=1][length=0].@grpc/grpc-jsthen feeds the empty payload to zlib, which throwsunexpected end of fileand surfaces in the UI as:Fix
Patch
@grpc/grpc-jssoCompressionHandler.readMessageshort-circuits a zero-length payload (which unambiguously decodes to an empty message) instead of attempting decompression:Single dispatch point → covers gzip/deflate; semantically correct since decompressing 0 bytes yields 0 bytes.
Changes
patches/@grpc+grpc-js+1.14.4.patch— the fix (applied viapatch-packageonpostinstall)grpc.test.ts— regression test feeding a gzip-flagged zero-length frame throughCompressionFilterVerification
Against a test server that emits
[compressed=1][length=0]+grpc-encoding: gzipfor empty messages:ERROR: 13 Failed to decompress...(reproduces #8659)SUCCESS {"article_ids":[]}Plus unit tests + lint passing.