diff --git a/lib/internal/webstreams/encoding.js b/lib/internal/webstreams/encoding.js index b5533b4287b65a..f316222ccbf0e8 100644 --- a/lib/internal/webstreams/encoding.js +++ b/lib/internal/webstreams/encoding.js @@ -20,6 +20,7 @@ const { customInspect } = require('internal/webstreams/util'); const { codes: { + ERR_INVALID_ARG_TYPE, ERR_INVALID_THIS, }, } = require('internal/errors'); @@ -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); diff --git a/test/wpt/status/encoding.json b/test/wpt/status/encoding.json index e78a8b3c0791be..f9378d7195a2a7 100644 --- a/test/wpt/status/encoding.json +++ b/test/wpt/status/encoding.json @@ -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"] },