[whatwg/streams] strategySizeAlgorithm validation in WritableStreamDefaultControllerGetChunkSize (Issue #1341)

daeyeon created an issue (whatwg/streams#1341)

### What is the issue with the Streams Standard?

Hi, while reviewing an [issue](https://github.com/nodejs/node/issues/57272) in Node.js, I noticed a case where the stream's state is `'closed'` when getting the chunk size, after the `sizeAlgorithm` has been cleared.

i. writableStreamDefaultWriterClose
ii. writableStreamClose
iii. writableStreamDefaultControllerClose
iv. writableStreamDefaultControllerAdvanceQueueIfNeeded
v. [WritableStreamDefaultControllerProcessClose(controller)](https://streams.spec.whatwg.org/#writable-stream-default-controller-process-close)

> 6. Perform ! WritableStreamDefaultControllerClearAlgorithms(controller).
>> 4. Set controller.[[strategySizeAlgorithm]] to undefined.

> 7.1. Perform ! WritableStreamFinishInFlightClose(stream).
>> 7. Set stream.[[state]] to "closed".

However, the current assertion below only checks `erroring` or `errored` states.

> WritableStreamDefaultControllerGetChunkSize(controller, chunk) performs the following steps:
> 1. If controller.[[strategySizeAlgorithm]] is undefined, then:
> 1.1. Assert: controller.[[stream]].[[state]] is "erroring" or "errored".
> 1.2. Return 1.


-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/issues/1341
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/streams/issues/1341@github.com>

Received on Sunday, 2 March 2025 19:00:23 UTC