Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stream: handle undefined chunks correctly in decode stream #55153

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/internal/webstreams/encoding.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const { customInspect } = require('internal/webstreams/util');

const {
codes: {
ERR_INVALID_ARG_TYPE,
ERR_INVALID_THIS,
},
} = require('internal/errors');
Expand Down Expand Up @@ -133,6 +134,9 @@ class TextDecoderStream {
this.#handle = new TextDecoder(encoding, options);
this.#transform = new TransformStream({
transform: (chunk, controller) => {
if (chunk === undefined) {
throw new ERR_INVALID_ARG_TYPE('chunk', 'string', chunk);
}
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
Loading