Skip to content

Commit

Permalink
stream: validate undefined sizeAlgorithm in WritableStream
Browse files Browse the repository at this point in the history
PR-URL: #56067
Fixes: #56014
Refs: whatwg/streams#1333
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
  • Loading branch information
jazelly authored Dec 20, 2024
1 parent 14803ea commit 57b21b1
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/internal/webstreams/writablestream.js
Original file line number Diff line number Diff line change
Expand Up @@ -1176,9 +1176,18 @@ function writableStreamDefaultControllerGetDesiredSize(controller) {
}

function writableStreamDefaultControllerGetChunkSize(controller, chunk) {
const {
stream,
sizeAlgorithm,
} = controller[kState];
if (sizeAlgorithm === undefined) {
assert(stream[kState].state === 'errored' || stream[kState].state === 'erroring');
return 1;
}

try {
return FunctionPrototypeCall(
controller[kState].sizeAlgorithm,
sizeAlgorithm,
undefined,
chunk);
} catch (error) {
Expand Down

0 comments on commit 57b21b1

Please sign in to comment.