- From: Mattias Buelens <notifications@github.com>
- Date: Sat, 02 Oct 2021 06:55:22 -0700
- To: whatwg/streams <streams@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/streams/pull/1168/c932756142@github.com>
I've fixed `ReadableStreamCancel`, `ReadableStreamClose` and `ReadableStreamError` so they empty the list of read requests *before* calling the close/error steps. That does indeed fix the async iterator tests.
Piping was trickier, because there's interaction with "shutdown with an action". Specifically, when `preventCancel = false`, we don't want to wait for the read to complete *before* we call `ReadableStreamCancel`. I suggest we change it to:
1. Wait until all writes have finished.
2. Perform *action*, and wait for it to complete.
3. Wait until all reads and writes have finished.
4. Finalize, passing along any error from step 2.
This works perfectly, except for [this one test](https://github.com/web-platform-tests/wpt/blob/e1e713c842e54ea0a9410ddc988b63d0e1d31973/streams/piping/error-propagation-backward.any.js#L403-L419):
```javascript
promise_test(t => {
const rs = recordingReadableStream();
const ws = recordingWritableStream();
const pipePromise = promise_rejects_exactly(t, error1, rs.pipeTo(ws, { preventCancel: true }),
'pipeTo must reject with the same error');
t.step_timeout(() => ws.controller.error(error1), 10);
return pipePromise.then(() => {
assert_array_equals(rs.eventsWithoutPulls, []);
assert_array_equals(ws.events, []);
});
}, 'Errors must be propagated backward: becomes errored after piping; preventCancel = true');
```
Because `preventCancel = true`, the pipe's read request never finishes, so it gets stuck. I believe this is the correct behavior though: we cannot cancel the stream, so we have to wait for the read to finish before we can safely release our reader.
I see two solutions:
* Change the test to somehow unblock the read request, e.g. by enqueuing a chunk on the readable after erroring the writable.
* Abort the read request without cancelling the stream, as suggested in #1103.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/pull/1168#issuecomment-932756142
Received on Saturday, 2 October 2021 13:55:34 UTC