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

Oh wait, hang on. That doesn't actually explain why `pipeTo()` works *even without* the `await flushAsyncEvents()`... 😅 

It looks like the problem is that, even when the pipe is *immediately* aborted (with an aborted `AbortSignal`), the reference implementation doesn't execute the abort actions in the first microtask. That's because we enter this `if` branch:
https://github.com/whatwg/streams/blob/e9355ce79925947e8eb496563d599c329769d315/reference-implementation/lib/abstract-ops/readable-streams.js#L293-L294


The implementation of `waitForWritesToFinish()` takes at least one microtask to [transform the `currentWrite` promise](https://github.com/whatwg/streams/blob/e9355ce79925947e8eb496563d599c329769d315/reference-implementation/lib/abstract-ops/readable-streams.js#L265-L268), and then we add another microtask because of the `uponFulfillment()` itself. By that time, the writable stream in this WPT test has become started, and the `abort()` call is handled *synchronously*.

I've tried fixing this for the case where the pipe didn't start *any* writes at all (https://github.com/whatwg/streams/pull/1208#discussion_r793162698), but that caused *even more problems*... 😛

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/issues/1229#issuecomment-1110264830

You are receiving this because you are subscribed to this thread.

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

Received on Tuesday, 26 April 2022 21:26:26 UTC