Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locked stream should be cancellable #41159

Closed
ronag opened this issue Dec 13, 2021 · 2 comments
Closed

Locked stream should be cancellable #41159

ronag opened this issue Dec 13, 2021 · 2 comments

Comments

@ronag
Copy link
Member

ronag commented Dec 13, 2021

Calling cancel(reason) on a locked readable stream should not cause invalid state error. I cannot see anything that would say so in the spec and doing so causes incompatibility with the fetch spec.

Refs: nodejs/undici#1138 (comment)
Refs: https://streams.spec.whatwg.org/#readable-stream-cancel

@Svanazar
Copy link

I am not sure if it is relevant but a section on cancel(reason) seems to be mentioning this behavior:

If ! IsReadableStreamLocked(this) is true, return a promise rejected with a TypeError exception.

from https://streams.spec.whatwg.org/#rs-cancel

@jasnell
Copy link
Member

jasnell commented Apr 21, 2022

Exactly what @Svanazar said. Throwing is the correct behavior. The rationale is that when a stream is locked, the reader takes over ownership of its lifecycle. The reader to which the stream is locked can cancel it but the stream itself cannot be directly canceled while locked.

@ronag ronag closed this as completed Apr 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants