Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c7ed2ff

Browse filesBrowse files
Nahee-Parktargos
authored andcommitted
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: #55153 Reviewed-By: Mattias Buelens <mattias@buelens.com> Reviewed-By: Matthew Aitken <maitken033380023@gmail.com>
1 parent aaea394 commit c7ed2ff
Copy full SHA for c7ed2ff

File tree

Expand file treeCollapse file tree

2 files changed

+4
-7
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+4
-7
lines changed
Open diff view settings
Collapse file

‎lib/internal/webstreams/encoding.js‎

Copy file name to clipboardExpand all lines: lib/internal/webstreams/encoding.js
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const { customInspect } = require('internal/webstreams/util');
2020

2121
const {
2222
codes: {
23+
ERR_INVALID_ARG_TYPE,
2324
ERR_INVALID_THIS,
2425
},
2526
} = require('internal/errors');
@@ -133,6 +134,9 @@ class TextDecoderStream {
133134
this.#handle = new TextDecoder(encoding, options);
134135
this.#transform = new TransformStream({
135136
transform: (chunk, controller) => {
137+
if (chunk === undefined) {
138+
throw new ERR_INVALID_ARG_TYPE('chunk', 'string', chunk);
139+
}
136140
const value = this.#handle.decode(chunk, { stream: true });
137141
if (value)
138142
controller.enqueue(value);
Collapse file

‎test/wpt/status/encoding.json‎

Copy file name to clipboardExpand all lines: test/wpt/status/encoding.json
-7Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,6 @@
6666
"streams/decode-utf8.any.js": {
6767
"requires": ["small-icu"]
6868
},
69-
"streams/decode-bad-chunks.any.js": {
70-
"fail": {
71-
"expected": [
72-
"chunk of type undefined should error the stream"
73-
]
74-
}
75-
},
7669
"streams/decode-non-utf8.any.js": {
7770
"requires": ["full-icu"]
7871
},

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.