diff --git a/lib/internal/webstreams/writablestream.js b/lib/internal/webstreams/writablestream.js index 5baaf20c30ba26..03b48dd043bc41 100644 --- a/lib/internal/webstreams/writablestream.js +++ b/lib/internal/webstreams/writablestream.js @@ -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) {