-
Notifications
You must be signed in to change notification settings - Fork 30k
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: fix y.pipe(x)+y.pipe(x)+y.unpipe(x) scenario #12746
stream: fix y.pipe(x)+y.pipe(x)+y.unpipe(x) scenario #12746
Conversation
CI: https://ci.nodejs.org/job/node-test-commit/9508/ Edit: CI failures are infra-related, CITGM compares good to master /cc @nodejs/streams |
lib/_stream_readable.js
Outdated
debug('onunpipe'); | ||
if (readable === src) { | ||
cleanup(); | ||
if (unpipeInfo.counter++ === 0) { |
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.
Nit: how about only incrementing inside to avoid incrementing when unnecessary? Or just use a boolean?
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.
@mscdex I’m fine either way, updated this to switch to a boolean
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.
Changes LGTM assuming CI and CITGM are green, we might want to mark this as semver-minor for safety reasons as it changes stream behavior.
Not sure, it isn’t really adding anything … if you think it’s a change that should be pointed out explicitly, then adding |
81ad497
to
ca8f430
Compare
Wanna just discuss this at the face to face this week?
…On Sat, Apr 29, 2017, 3:40 PM Anna Henningsen ***@***.***> wrote:
we might want to mark this as semver-minor for safety reasons as it
changes stream behavior
Not sure, it isn’t really adding anything … if you think it’s a change
that should be pointed out explicitly, then adding notable-change sounds
better. But really, this is a very very niche use case that’s being fixed,
even for streams…
—
You are receiving this because you are on a team that was mentioned.
Reply to this email directly, view it on GitHub
<#12746 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABE4nxSRpld7Miewyr6PQxWfxpH0wWcSks5r05JHgaJpZM4NMV5N>
.
|
@calvinmetcalf I mean, sure, if you think that that makes anything easier, we can talk in person … but it might be good to know what you’d like to discuss? 😄 |
Whether this is semver minor or not
…On Sun, Apr 30, 2017, 10:22 AM Anna Henningsen ***@***.***> wrote:
@calvinmetcalf <https://github.com/calvinmetcalf> I mean, sure, if you
think that that makes anything easier, we can talk in person … but it might
be good to know what you’d like to discuss? 😄
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#12746 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABE4n3-mSiFqWW2aSkM7sWLRHM6CgGAiks5r1Jk9gaJpZM4NMV5N>
.
|
Sure … but I don’t have a problem discussing it here, either. I know the streams WG has a good chance of being quite complete in Berlin, but there might be other people with thoughts on this that can’t make it there. (That doesn’t mean we can’t talk about it in person if we don’t come to a conclusion here). I would say that this is semver-patch, because it fixes a bug; the current behaviour is definitely broken (or needs to be document as something that’s just fundamentally not supported), and this is a way to make the behaviour at least consistent in a way that would match my expectations as a streams user, and presumably @ovikholt’s expectations, too. I would say that this is not semver-major because the edge case that is affected by this change would just be broken before, so there’s no reason to believe anybody relies on it. I would say that this is not semver-minor because it doesn’t add a feature to the API. It does add another parameter to an event callback, but one that’s for internal use, that’s intentionally undocumented and that userland applications won’t really be able to use. I wish there would be an easier way to hide it, but I don’t see any (at least as long as we’re also talking about solutions that include all environments supported by readable-stream). If we want to be careful, then landing it in current and waiting a reasonably long time before backporting it to LTS seems like a better approach than assigning it a semver level out of caution. |
I'm not convinced of this PR. I think Would you mind adding a test that does |
I agree, supporting that is odd (especially for non-object mode) and we should consider un-supporting it. Are you okay with this change as a bugfix, though?
Done! |
ca8f430
to
87cdba9
Compare
Yes, I'm ok as being a backportable bugfix. We can aim to port this to lts as well. |
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
Just one nit, can you amend the commit and the title to the PR to |
Fix the uncommon situation when a readable stream is piped twice into the same destination stream, and then unpiped once. Previously, the `unpipe` event handlers weren’t able to tell whether they were corresponding to the “right” conceptual pipe that was being removed; this fixes this by adding a counter to the `unpipe` event handler and only removing a single piping destination at most. Fixes: nodejs#12718
87cdba9
to
86b9243
Compare
Done! |
Fantastic, you can go ahead and merge this for me. @calvinmetcalf have you got any other concerns? |
no I'm all set
…On Tue, May 2, 2017 at 5:03 PM Matteo Collina ***@***.***> wrote:
Fantastic, you can go ahead and merge this for me. @calvinmetcalf
<https://github.com/calvinmetcalf> have you got any other concerns?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#12746 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABE4n-jc2r-U1O3O80P8yYh-TBj0Pameks5r10WvgaJpZM4NMV5N>
.
|
Landed in 6993eb0 This is streams code and a very edge-case-y thing, so it might be good to let it sit in Current for a while before backporting. |
Fix the uncommon situation when a readable stream is piped twice into the same destination stream, and then unpiped once. Previously, the `unpipe` event handlers weren’t able to tell whether they were corresponding to the “right” conceptual pipe that was being removed; this fixes this by adding a counter to the `unpipe` event handler and only removing a single piping destination at most. Fixes: #12718 PR-URL: #12746 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Fix the uncommon situation when a readable stream is piped twice into the same destination stream, and then unpiped once. Previously, the `unpipe` event handlers weren’t able to tell whether they were corresponding to the “right” conceptual pipe that was being removed; this fixes this by adding a counter to the `unpipe` event handler and only removing a single piping destination at most. Fixes: nodejs#12718 PR-URL: nodejs#12746 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This PR makes sure the object emitted as the 'unpipe' event in the destination stream is not shared between destination, as it would be muted. Refs: #12746 PR-URL: #18266 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This PR makes sure the object emitted as the 'unpipe' event in the destination stream is not shared between destination, as it would be muted. Refs: #12746 PR-URL: #18266 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This PR makes sure the object emitted as the 'unpipe' event in the destination stream is not shared between destination, as it would be muted. Refs: #12746 PR-URL: #18266 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This PR makes sure the object emitted as the 'unpipe' event in the destination stream is not shared between destination, as it would be muted. Refs: #12746 PR-URL: #18266 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This PR makes sure the object emitted as the 'unpipe' event in the destination stream is not shared between destination, as it would be muted. Refs: #12746 PR-URL: #18266 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Anna Henningsen <anna@addaleax.net>
@MylesBorins any reason to not backport this to v6.x? |
I think backporting both should be fine by now, it’s been almost a year. :) |
+1 for backporting both. |
@lpinca done 🎉 Will report back if there is any weirdness |
Fix the uncommon situation when a readable stream is piped twice into the same destination stream, and then unpiped once. Previously, the `unpipe` event handlers weren’t able to tell whether they were corresponding to the “right” conceptual pipe that was being removed; this fixes this by adding a counter to the `unpipe` event handler and only removing a single piping destination at most. Fixes: #12718 PR-URL: #12746 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This PR makes sure the object emitted as the 'unpipe' event in the destination stream is not shared between destination, as it would be muted. Refs: #12746 PR-URL: #18266 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This PR makes sure the object emitted as the 'unpipe' event in the destination stream is not shared between destination, as it would be muted. Refs: nodejs#12746 PR-URL: nodejs#18266 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Fix the uncommon situation when a readable stream is piped twice into
the same destination stream, and then unpiped once.
Previously, the
unpipe
event handlers weren’t able to tell whetherthey were corresponding to the “right” conceptual pipe that was being
removed; this fixes this by adding a counter to the
unpipe
eventhandler and only removing a single piping destination at most.
Fixes: #12718
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
stream