Uh oh!
There was an error while loading. Please reload this page.
stream: support AbortSignal in constructor - #36431
Conversation
ronag
left a comment
There was a problem hiding this comment.
Won't it be added twice in case of duplex?
Uh oh!
There was an error while loading. Please reload this page.
benjamingr
commented
Dec 7, 2020
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. |
benjamingr
commented
Dec 7, 2020
|
ronag
commented
Dec 7, 2020
I was more thinking about |
benjamingr
commented
Dec 7, 2020
Yes, that's probably fine, the signal is added twice, destroys the stream twice and the second destroy is ignored. |
benjamingr
commented
Dec 7, 2020
I added a test for duplex that makes sure |
ronag
commented
Dec 7, 2020
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
03ff368CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| }); | ||
| let count = 0; | ||
| duplex.on('error', common.mustCall((e) => { | ||
| assert.strictEqual(count++, 0); // Ensure not called twice |
There was a problem hiding this comment.
The mustCall already handles this doesn't it?
There was a problem hiding this comment.
@jasnell I want to make sure error is called, but not called twice - I'd need a comon.mustCallOnce or something.
nodejs-github-bot
commented
Dec 10, 2020
nodejs-github-bot
commented
Dec 10, 2020
PR-URL: #36431 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
benjamingr
commented
Dec 10, 2020
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
addAbortSignalinternally to make maintenance easier.Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes