Skip to content

Commit

Permalink
stream: handle undefined chunks correctly in decode stream
Browse files Browse the repository at this point in the history
Align TextDecoderStream behavior with WPT requirements by treating
undefined chunks as errors. This change ensures that TextDecoderStream
properly handles unexpected chunk types and throws an error when
receiving undefined input.

This update addresses the failing WPT for decode stream error handling.
  • Loading branch information
Nahee-Park committed Sep 28, 2024
1 parent 6d1cd50 commit 1ac2e8b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
3 changes: 3 additions & 0 deletions lib/internal/webstreams/encoding.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ class TextDecoderStream {
this.#handle = new TextDecoder(encoding, options);
this.#transform = new TransformStream({
transform: (chunk, controller) => {
if (chunk === undefined) {
throw new ERR_INVALID_THIS('TextDecoderStream');
}
const value = this.#handle.decode(chunk, { stream: true });
if (value)
controller.enqueue(value);
Expand Down
7 changes: 0 additions & 7 deletions test/wpt/status/encoding.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,6 @@
"streams/decode-utf8.any.js": {
"requires": ["small-icu"]
},
"streams/decode-bad-chunks.any.js": {
"fail": {
"expected": [
"chunk of type undefined should error the stream"
]
}
},
"streams/decode-non-utf8.any.js": {
"requires": ["full-icu"]
},
Expand Down

0 comments on commit 1ac2e8b

Please sign in to comment.