whatwg / streams

Streams Standard
https://streams.spec.whatwg.org/
Other
1.35k stars 160 forks source link

Should the "set up" algorithm for IDL-created WritableStreams wrap the write algorithm? #1253

Open saschanaz opened 1 year ago

saschanaz commented 1 year ago

Currently it wraps all others except the write one:

https://streams.spec.whatwg.org/#writablestream-set-up

Perform ! SetUpWritableStreamDefaultController(stream, controller, startAlgorithm, writeAlgorithm, closeAlgorithmWrapper, abortAlgorithmWrapper, highWaterMark, sizeAlgorithm).

Perhaps because writeAlgorithm is required here and others are optional, but then TransformStream does wrap the transform algorithm.

https://streams.spec.whatwg.org/#transformstream-set-up

Let transformAlgorithmWrapper be an algorithm that runs these steps given a value chunk:

Should WritableStream do the same?

ricea commented 1 year ago

That's an interesting observation. I can justify it after-the-fact by saying that a writeAlgorithm should always return a promise in order to correctly support backpressure. On the other hand, none of the platform transforms I've defined return an unsettled promise.

Probably there is simply no need to wrap it? If there are two or more standards that always return a settled promise then it might we worth doing so that they could be more concise.