mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
stream: handle undefined chunks correctly in decode stream
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. PR-URL: https://github.com/nodejs/node/pull/55153 Reviewed-By: Mattias Buelens <mattias@buelens.com> Reviewed-By: Matthew Aitken <maitken033380023@gmail.com>
This commit is contained in:
parent
bbf08c6a1b
commit
3111ed7011
@ -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);
|
||||
|
@ -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"]
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user