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
stream: add abort signal for ReadableStream and WritableStream #46273
base: main
Are you sure you want to change the base?
stream: add abort signal for ReadableStream and WritableStream #46273
Conversation
|
Review requested:
|
| @@ -13,6 +13,7 @@ const kIsReadable = Symbol('kIsReadable'); | |||
| const kIsDisturbed = Symbol('kIsDisturbed'); | |||
|
|
|||
| const kIsClosedPromise = SymbolFor('nodejs.webstream.isClosedPromise'); | |||
| const kControllerErrorFunction = SymbolFor('nodejs.webstream.controllerErrorFunction'); | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we using Symbol.for here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used the similar pattern to what we followed over here #46205 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aduh95 I presume Node.js streams or another part that exists both in core and userland added this for interoperability (so that require("node:stream") and require("readable-stream") interoperate) and then everyone (probably me too) saw the code and cargo culted. Probably a bunch at the point we moved private variables to symbols when privates were not supported in snapshots back then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's also arguably easier to debug "from the outside" but not by a considerable margin.
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
|
Added more few more tests should be covering most scenarios |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat (I'm +1 on this and approving). I'll add some questions later.
|
Hey, consider going through the standards track and adding this to streams through WHATAG (like a signal parameter to the constructor). This is not instead of this PR but in addition. |
|
Can you also please add to the docs for addAbortSignal at stream.md ? |
|
Heh, jinx. |
Adding! |
Hi so are you thinking something like |
|
Adding a signal to the ReadableStream constructor is not something I would really expect to see happen in whatwg, particularly since there is already a way of cancelling the stream via the existing API. Could be worth a try but I'd be surprised if it were accepted. |
|
Have added to docs @benjamingr @jasnell |
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add an history entry in the YAML comment please?
|
What should the version be v19.5.0? |
It should be node/doc/contributing/pull-requests.md Lines 125 to 136 in 5af2021
|
|
Added the version @aduh95 |


Refs: #39316