streams
streams copied to clipboard
"Let returnValue be the result of performing con..."
https://streams.spec.whatwg.org/commit-snapshots/0ebe4b042e467d9876d80ae045de3843092ad797/#writable-stream-default-controller-get-chunk-size
Let returnValue be the result of performing controller.[[strategySizeAlgorithm]], passing in chunk
Maybe we should explicitly handle the case where controller.[[strategySizeAlgorithm]] is undefined here? This can happen after ClearAlgorithms() is called. It doesn't make any difference to the reference implementation, as it treats that case as an abrupt completion, but it might be helpful for other implementations to make it an explicit step.
How could this occur? I would have assumed we'd never call WritableStreamDefaultControllerGetChunkSize after ClearAlgorithms.
However, if it can occur, then yes, this is definitely a bug, and we should handle it explicitly.
Some time ago I moved most of the state checks until after the call to strategy.size(). This avoids having to repeat the checks in case strategy.size() changed something. But it also means that strategy.size() can be called after the stream is closed. Or it could, until I added ClearAlgorithms().
ClearAlgorithms() was not intended to have any side-effects, but this particular side-effect seems acceptable. I will have to write a test for it, obviously.