-
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
fs: do not emit 'stop' watch event synchronously #8524
Conversation
LGTM pending CI. |
@claudiorodriguez Just wondering if
I noted that |
@imyller just tried that change locally, it passes all tests successfully. I'd be inclined to make the change, it makes sense, although maybe someone from @nodejs/collaborators can chime in, if |
( |
@claudiorodriguez 2 suggestions from me:
|
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.
While I'm good with this change in general, I'm wondering if this needs to be semver-major due to the change in timing? I don't believe it does but want to be careful
b6b1a55
to
df27869
Compare
@yorkie added the test, PTAL New CI: https://ci.nodejs.org/job/node-test-pull-request/4123/ |
self.emit('stop'); | ||
process.nextTick(function() { | ||
self.emit('stop'); | ||
}); |
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 we avoid allocating a new closure here? When calling stop()
on a massive tree of objects, we will be allocating a lot of closures for nothing.
this._handle.onstop = function() {
process.nextTick(emitStop, self)
}
// to be put a root level
function emitStop(self) {
self.emit('stop');
}
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.
@mcollina changed, PTAL
Emits 'stop' event for fs.watchFile on process.nextTick to fix 'maximum call stack size exceeded' error when `stop` is called synchronously after listener is attached. Fixes: nodejs#8421
df27869
to
e4028ac
Compare
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
@claudiorodriguez ... no, I can't think of anything either. As I said, this should be perfectly fine. |
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.
LGTM :)
Landing:
/ping @jasnell you were thinking about adding semver-major label for this. Still relevant? |
Emits 'stop' event for fs.watchFile on process.nextTick to fix 'maximum call stack size exceeded' error when `stop` is called synchronously after listener is attached. PR-URL: nodejs#8524 Fixes: nodejs#8421 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Ilkka Myller <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yorkie Liu <[email protected]>
landed in 1b97774 |
To be safe, I've added |
Emits 'stop' event for fs.watchFile on process.nextTick to fix 'maximum call stack size exceeded' error when `stop` is called synchronously after listener is attached. PR-URL: #8524 Fixes: #8421 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Ilkka Myller <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yorkie Liu <[email protected]>
Hm, bump? Does anybody feel this should be |
Changes event timing, sounds major to me |
Checklist
make -j4 test
(UNIX), orvcbuild test nosign
(Windows) passesAffected core subsystem(s)
Description of change
Emits 'stop' event for fs.watchFile on process.nextTick
to fix 'maximum call stack size exceeded' error when
stop
is called synchronously after listener is attached.Fixes: #8421