Skip to content

Commit 86d07e9

Browse files
committed
Fix attempting to get the chunk size after strategy is cleared
Although a better fix might be to delay size calculation until we've verified that we're not in the erroring or errored states, that has observable differences for certain bad-strategy cases already in the WPT suite, and multiple implementations seem to have converged on this particular fix already. Closes #1331.
1 parent 8ebee1f commit 86d07e9

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

index.bs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5373,6 +5373,10 @@ The following abstract operations support the implementation of the
53735373
id="writable-stream-default-controller-get-chunk-size">WritableStreamDefaultControllerGetChunkSize(|controller|,
53745374
|chunk|)</dfn> performs the following steps:
53755375

5376+
1. If |controller|.[=WritableStreamDefaultController/[[strategySizeAlgorithm]]=] is undefined, then:
5377+
1. Assert: |controller|.[=WritableStreamDefaultController/[[stream]]=].[=WritableStream/[[state]]=] is "`erroring`" or
5378+
"`errored`".
5379+
1. Return 1.
53765380
1. Let |returnValue| be the result of performing
53775381
|controller|.[=WritableStreamDefaultController/[[strategySizeAlgorithm]]=], passing in |chunk|,
53785382
and interpreting the result as a [=completion record=].

reference-implementation/lib/abstract-ops/writable-streams.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,11 @@ function WritableStreamDefaultControllerGetBackpressure(controller) {
662662
}
663663

664664
function WritableStreamDefaultControllerGetChunkSize(controller, chunk) {
665+
if (controller._strategySizeAlgorithm === undefined) {
666+
assert(controller._stream._state === 'erroring' || controller._stream._state === 'errored');
667+
return 1;
668+
}
669+
665670
try {
666671
return controller._strategySizeAlgorithm(chunk);
667672
} catch (chunkSizeE) {

0 commit comments

Comments
 (0)