-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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: support AbortSignal in constructor #36431
stream: support AbortSignal in constructor #36431
Conversation
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.
Won't it be added twice in case of duplex?
Maybe? Probably not because destroy already checks that stream is destroyed and does not call _destroy.
|
I'm not sure I follow. How is destroy related? This happens in the constructor which is invoked for both Readable and Writable. |
|
I was more thinking about |
Yes, that's probably fine, the signal is added twice, destroys the stream twice and the second destroy is ignored. |
I added a test for duplex that makes sure |
Can't we just make use of |
We can, would you prefer that? Edit: I think I prefer that too. Pushed a fix + the "ignore bad signal" logic for the construct version |
4579e20
to
03ff368
Compare
}); | ||
let count = 0; | ||
duplex.on('error', common.mustCall((e) => { | ||
assert.strictEqual(count++, 0); // Ensure not called twice |
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.
The mustCall already handles this doesn't it?
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.
@jasnell I want to make sure error
is called, but not called twice - I'd need a comon.mustCallOnce
or something.
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
PR-URL: #36431 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Landed with NCU in 040a27a 🎉 |
PR-URL: #36431 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Notable changes: child_process: * (SEMVER-MINOR) add signal support to spawn (Benjamin Gruenbaum) #36432 doc: * add PoojaDurgad to collaborators (Pooja D P) #36511 lib: * (SEMVER-MINOR) support BigInt in querystring.stringify (raisinten) #36499 src: * (SEMVER-MINOR) add way to get IsolateData and allocator from Environment (Anna Henningsen) #36441 * (SEMVER-MINOR) allow preventing SetPrepareStackTraceCallback (Shelley Vohr) #36447 stream: * (SEMVER-MINOR) support abortsignal in constructor (Benjamin Gruenbaum) #36431 PR-URL: #36597
Notable changes: child_process: * (SEMVER-MINOR) add signal support to spawn (Benjamin Gruenbaum) #36432 doc: * add PoojaDurgad to collaborators (Pooja D P) #36511 lib: * (SEMVER-MINOR) support BigInt in querystring.stringify (raisinten) #36499 src: * (SEMVER-MINOR) add way to get IsolateData and allocator from Environment (Anna Henningsen) #36441 * (SEMVER-MINOR) allow preventing SetPrepareStackTraceCallback (Shelley Vohr) #36447 stream: * (SEMVER-MINOR) support abortsignal in constructor (Benjamin Gruenbaum) #36431 PR-URL: #36597
Notable changes: child_process: * (SEMVER-MINOR) add signal support to spawn (Benjamin Gruenbaum) #36432 doc: * add PoojaDurgad to collaborators (Pooja D P) #36511 lib: * (SEMVER-MINOR) support BigInt in querystring.stringify (raisinten) #36499 src: * (SEMVER-MINOR) add way to get IsolateData and allocator from Environment (Anna Henningsen) #36441 * (SEMVER-MINOR) allow preventing SetPrepareStackTraceCallback (Shelley Vohr) #36447 stream: * (SEMVER-MINOR) support abortsignal in constructor (Benjamin Gruenbaum) #36431 PR-URL: #36597
As requested by @ronag (I agree it's useful especially when subclassing streams) - an API to pass AbortSignal directly to the readable/writeable constructor + tests.
It uses
addAbortSignal
internally to make maintenance easier.Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes