[whatwg/streams] `SetUpTransformStreamDefaultControllerFromTransformer` doesn't ensure that `transformAlgorithm` and `flushAlgorithm` return `Promise` (Issue #1201)

Step 1 of [TransformStreamDefaultControllerPerformTransform](https://streams.spec.whatwg.org/#transform-stream-default-controller-perform-transform) and step 3 of [TransformStreamDefaultSinkCloseAlgorithm](https://streams.spec.whatwg.org/#transform-stream-default-sink-close-algorithm) assume that `transformAlgorithm` and `flushAlgorithm` always return a `Promise`.

While this is true if the algorithms were set via the [TransformStream Set Up](https://streams.spec.whatwg.org/#transformstream-set-up) operation, it's not guaranteed for if a `TransformStream` is created via `new TransformStream()`: if a `transformer` argument with `transform` and `flush` methods on it is passed to the constructor, the algorithms stored result in their completion result, which might or might not be a `Promise`.

I *think* this can be addressed by creating the creation of `{transform,flush}AlgorithmWrapper` from the `Set Up` operation into [SetUpTransformStreamDefaultController](https://streams.spec.whatwg.org/#set-up-transform-stream-default-controller), which is called from both ways to create/initialize a `TransformStream`.

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

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

Received on Sunday, 26 December 2021 11:37:12 UTC