Version
v17.2.0
Platform
Darwin jim-book 19.6.0 Darwin Kernel Version 19.6.0: Tue Oct 12 18:34:05 PDT 2021; root:xnu-6153.141.43~1/RELEASE_X86_64 x86_64
Subsystem
stream/web
What steps will reproduce the bug?
var r = new ReadableStream({cancel(err) { return Promise.reject(new Error("inner")) }});
r.cancel(new Error("outer")).then(()=>console.log("success",r),(e)=>console.log("failed", e.message, r));
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior?
failed inner ReadableStream { locked: false, state: 'errored', supportsBYOB: false }
What do you see instead?
failed inner ReadableStream { locked: false, state: 'closed', supportsBYOB: false }
Additional information
The WHATWG spec says:
cancel(reason), of type UnderlyingSourceCancelCallback
...
If the shutdown process is asynchronous, it can return a promise to signal success or failure; the result will be communicated via the return value of the cancel() method that was called. Additionally, a rejected promise will error the stream, instead of letting it close. Throwing an exception is treated the same as returning a rejected promise.
But in Node, whether the cancel method synchronously throws, or returns a rejected Promise, or asynchronously throws, in all of these cases the stream is put into "closed" state rather than "errored".
Version
v17.2.0
Platform
Darwin jim-book 19.6.0 Darwin Kernel Version 19.6.0: Tue Oct 12 18:34:05 PDT 2021; root:xnu-6153.141.43~1/RELEASE_X86_64 x86_64
Subsystem
stream/web
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior?
failed inner ReadableStream { locked: false, state: 'errored', supportsBYOB: false }
What do you see instead?
failed inner ReadableStream { locked: false, state: 'closed', supportsBYOB: false }
Additional information
The WHATWG spec says:
But in Node, whether the
cancelmethod synchronously throws, or returns a rejected Promise, or asynchronously throws, in all of these cases the stream is put into "closed" state rather than "errored".