Skip to content

Commit fe5f7bc

Browse files
jazellymarco-ippolito
authored andcommitted
stream: validate undefined sizeAlgorithm in WritableStream
PR-URL: #56067 Fixes: #56014 Refs: whatwg/streams#1333 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Jake Yuesong Li <[email protected]>
1 parent 5083bbb commit fe5f7bc

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/internal/webstreams/writablestream.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -1167,9 +1167,18 @@ function writableStreamDefaultControllerGetDesiredSize(controller) {
11671167
}
11681168

11691169
function writableStreamDefaultControllerGetChunkSize(controller, chunk) {
1170+
const {
1171+
stream,
1172+
sizeAlgorithm,
1173+
} = controller[kState];
1174+
if (sizeAlgorithm === undefined) {
1175+
assert(stream[kState].state === 'errored' || stream[kState].state === 'erroring');
1176+
return 1;
1177+
}
1178+
11701179
try {
11711180
return FunctionPrototypeCall(
1172-
controller[kState].sizeAlgorithm,
1181+
sizeAlgorithm,
11731182
undefined,
11741183
chunk);
11751184
} catch (error) {

0 commit comments

Comments
 (0)