Skip to content

Commit

Permalink
stream: validate undefined sizeAlgorithm in WritableStream
Browse files Browse the repository at this point in the history
  • Loading branch information
jazelly committed Nov 29, 2024
1 parent ae8280c commit 0cd61ce
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 0cd61ce

Please sign in to comment.