stream: improve Web Compression spec compliance#62107
Open
panva wants to merge 5 commits intonodejs:mainfrom
Open
stream: improve Web Compression spec compliance#62107panva wants to merge 5 commits intonodejs:mainfrom
panva wants to merge 5 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:
|
7ad3343 to
17679f8
Compare
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. Unskip WPT compression bad-chunks tests which now run instead of hang. Unskip WPT compression bad-chunks tests which now run instead of hang and mark the remaining expected failures.
17679f8 to
46c309e
Compare
Per the Compression Streams spec, chunks must be BufferSource which excludes SharedArrayBuffer-backed views. Add validation to both CompressionStream and DecompressionStream that rejects chunks backed by SharedArrayBuffer with a typed TypeError.
161b9cf to
305ab4c
Compare
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.
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 206377 +65924
Branches 21801 39529 +17728
==========================================
+ Hits 128694 185018 +56324
- Misses 11536 13468 +1932
- Partials 223 7891 +7668
🚀 New features to boost your workflow:
|
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
fixesimproves 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.
Unskip WPT compression bad-chunks tests which now run instead of hang and mark the remaining expected failures.
stream: reject SharedArrayBuffer-backed chunks in web compressionPer the Compression Streams spec, chunks must be BufferSource which excludes SharedArrayBuffer-backed views. Add validation to both CompressionStream and DecompressionStream that rejects chunks backed by SharedArrayBuffer with a typed TypeError.
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.