[whatwg/streams] Do the abort steps of ReadableStreamPipeTo really guarantee the abort callback to be called before cancel? (Issue #1229)

Step 14 of the https://streams.spec.whatwg.org/#readable-stream-pipe-to is basically `Promise.all([writable.abort(), readable.cancel()])`, assuming the states are writable/readable respectively. One WPT test for this asserts that `abort()` is called before `cancel()`: https://github.com/web-platform-tests/wpt/blob/285addceabb4443562a9b93d789b17230c3d6e20/streams/piping/abort.any.js#L215-L237

Blink passes this test, but not sure how. A slightly modified test without AbortSignal shows that the abort callback is called asynchronously, so I'd expect same for the AbortSignal test:

```js
promise_test(t => {
  const events = [];
  const rs = new ReadableStream({
    pull(controller) {
      controller.error('failed to abort');
    },
    cancel() {
      events.push('cancel');
      return Promise.reject(error1);
    }
  }, hwm0);
  const ws = new WritableStream({
    abort() {
      events.push('abort');
      return Promise.reject(error2);
    }
  });
  return promise_rejects_exactly(t, error1, Promise.all([ws.abort(), rs.cancel()]), 'pipeTo should reject')
      .then(() => assert_array_equals(events, ['cancel', 'abort'], 'abort() should be called before cancel()'));
}, '');
```

Am I understanding something wrong?

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

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

Received on Tuesday, 26 April 2022 20:41:17 UTC