stream: improve Web Compression spec compliance#62107
Open
panva wants to merge 4 commits intonodejs:mainfrom
Open
stream: improve Web Compression spec compliance#62107panva wants to merge 4 commits intonodejs:mainfrom
panva wants to merge 4 commits intonodejs:mainfrom
Conversation
Add incremental report writing after each spec completes and on worker errors so that reports survive if the process is killed before the exit handler runs. Add bytes() method to readAsFetch() to match the Response API used by newer WPT tests.
Collaborator
|
Review requested:
|
305ab4c to
9fb0878
Compare
anonrig
approved these changes
Mar 5, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #62107 +/- ##
==========================================
- Coverage 91.62% 89.65% -1.98%
==========================================
Files 337 676 +339
Lines 140453 206392 +65939
Branches 21801 39524 +17723
==========================================
+ Hits 128694 185044 +56350
- Misses 11536 13473 +1937
- Partials 223 7875 +7652
🚀 New features to boost your workflow:
|
Collaborator
Renegade334
reviewed
Mar 5, 2026
9fb0878 to
2b55f7c
Compare
7740fc4 to
0b7f47c
Compare
MattiasBuelens
approved these changes
Mar 5, 2026
This comment was marked as outdated.
This comment was marked as outdated.
Renegade334
reviewed
Mar 5, 2026
0b7f47c to
1dd8f13
Compare
Member
Author
|
@Renegade334 done |
Renegade334
approved these changes
Mar 5, 2026
Member
Renegade334
left a comment
There was a problem hiding this comment.
Would be good to get another pair of eyes on the Transform adapter error logic, but LGTM!
Pass rejectGarbageAfterEnd: true to createInflateRaw() and createBrotliDecompress(), matching the behavior already in place for deflate and gzip. The Compression Streams spec treats any data following a valid compressed payload as an error. When the underlying Node.js stream throws synchronously from write() (e.g. zlib rejects an invalid chunk type), destroy the stream so that the readable side is also errored. Without this, the readable side hangs forever waiting for data that will never arrive. Introduce a kValidateChunk callback option in the webstreams adapter layer. Compression streams use this to validate that chunks are BufferSource instances not backed by SharedArrayBuffer, replacing the previous monkey-patching of the underlying handle's write method. Unskip WPT compression bad-chunks tests which now run instead of hang and mark the remaining expected failures.
Convert brotli decompression errors to TypeError to match the Compression Streams spec, by extending handleKnownInternalErrors() in the adapters layer to recognize brotli error codes. This replaces the manual error event handler on DecompressionStream which was redundant with the adapter's built-in error propagation.
1dd8f13 to
c28a421
Compare
Renegade334
approved these changes
Mar 5, 2026
This comment was marked as outdated.
This comment was marked as outdated.
Collaborator
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.
Investigating why wpt.fyi daily runs took 26 minutes and then started taking 75 minutes last week lead me down this road.
Daily epoch synced WPTs were hanging again on test-compression, the switch to arm kicked in tools/test.py increase in timeouts (hence going from 26 to 75 minutes), and because the entire WPT subsuite errored there were no compression tests reported to wpt.fyi.
This PR updates the WPTs (some of which are no longer tentative) and improves the conformance of CompressionStream and DecompressionStream to the WHATWG Compression standard.
test: update WPT compression to ae05f5cb53Simple WPT update
test: improve WPT report runnerAdd incremental report writing after each spec completes and on worker errors so that reports survive if the process is killed before the exit handler runs.
Add bytes() method to readAsFetch() to match the Response API used by newer WPT tests.
stream: improve Web Compression spec compliancePass rejectGarbageAfterEnd: true to createInflateRaw() and createBrotliDecompress(), matching the behavior already in place for deflate and gzip. The Compression Streams spec treats any data following a valid compressed payload as an error.
When the underlying Node.js stream throws synchronously from write() (e.g. zlib rejects an invalid chunk type), destroy the stream so that the readable side is also errored. Without this, the readable side hangs forever waiting for data that will never arrive.
Introduce a kValidateChunk callback option in the webstreams adapter layer. Compression streams use this to validate that chunks are BufferSource instances not backed by SharedArrayBuffer, rather than monkey-patching the underlying handle's write method.
Unskip WPT compression bad-chunks tests which now run instead of hang and mark the remaining expected failures.
stream: fix brotli error handling in web compression streamsConvert brotli decompression errors to TypeError to match the Compression Streams spec, by extending handleKnownInternalErrors() in the adapters layer to recognize brotli error codes.
This replaces the manual error event handler on DecompressionStream which was redundant with the adapter's built-in error propagation.