[whatwg/streams] Test or specification problem with TransformStream writer.cancel and calling controller.error (Issue #1296)

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

There is a test for TansformStream cancel (#1283) called 
> readable.cancel() and a parallel writable.close() should reject if a transformer.cancel() calls controller.error()

https://github.com/web-platform-tests/wpt/blob/4ab37a2aa733a03162ce2d5e3782d5da7940c330/streams/transform-streams/cancel.any.js#L79

I think that test is wrong or the specification for [`TransformStreamDefaultSourceCancelAlgorithm`](https://streams.spec.whatwg.org/#transform-stream-default-source-cancel) is wrong.
We can observe in that test that the promise for cancel callback is going to be fulfilled. So we are in
> Step 7.1. If cancelPromise was fulfilled, then:
The next step is 
> If writable.[[state]] is "errored", reject controller.[[finishPromise]] with writable.[[storedError]].

I think this step is not going to be taken, because the [[state]] is "erroring". As set by `controller.error`, via WritableStreamStartErroring.

The whole path is
- TransformStreamDefaultControllerError
- TransformStreamError
- TransformStreamErrorWritableAndUnblockWrite
- WritableStreamDefaultControllerErrorIfNeeded
- WritableStreamDefaultControllerError
- WritableStreamStartErroring

So this could be fixed by changing the condition to 
> If writable.[[state]] is "errored" or "erroring"

Or of course adjusting the test to except a different promise resolution.

@lucacasonato @MattiasBuelens 

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

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

Received on Saturday, 14 October 2023 22:49:03 UTC