Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.4k
src: make FSEventWrap/StatWatcher::Start more robust#17432
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
TimothyGu commented Dec 3, 2017
src/fs_event_wrap.cc Outdated
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.
For consistency with the surrounding code, maybe write this as return args.GetReturnValue().Set(0); without braces.
test/parallel/test-fs-watch.js Outdated
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.
Doesn't the linter complain about using two spaces before //?
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.
No it doesn't, though fixed anyway.
src/node_stat_watcher.cc Outdated
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.
This is wrong when Start() is called with different arguments than last time. This should work:
uv_fs_poll_stop(wrap->watcher_); uv_fs_poll_start(wrap->watcher_, Callback, *path, interval); // Safe, uv_ref/uv_unref are idempotent.if (persistent) uv_ref(reinterpret_cast<uv_handle_t*>(wrap->watcher_)); elseuv_unref(reinterpret_cast<uv_handle_t*>(wrap->watcher_));And while we're here, this code really ought to check the return value of uv_fs_poll_start() (and uv_fs_poll_stop() too, although it can't fail in the current implementation.)
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.
Start() is not part of the external API, and no guarantees were made whether it works with different arguments or not. On the other hand, the proposed solution breaks compatibility.
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.
Then why don't you make it throw an exception? Methods should not silently do the wrong thing, that's arguably worse than aborting.
On the other hand, the proposed solution breaks compatibility.
In what way?
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 added test currently throws no exception. If I make it throw an exception it would be breaking compatibility.
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.
What do you mean? There are no compatibility issues because it was aborting before.
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 was aborting in FSEventWrap, not StatWatcher. This was simply tacked on as a similar change that improves the current behavior in a similar way.
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 wouldn't use the word 'improves'. StatWatcher already worked mostly like I proposed in my first comment and that would be an acceptable change for FSEventWrap too, as would throwing an exception. Silently ignoring changes is the worst possible solution however.
924f5f6 to b4fd89eCompareBridgeAR commented Dec 12, 2017
PR-URL: nodejs#17432Fixes: nodejs#17430 Reviewed-By: James M Snell <[email protected]>
addaleax commented Dec 13, 2017
Landed in cd71fc1 |
bnoordhuis commented Dec 13, 2017
#17432 (comment) is still unfixed. |
PR-URL: #17432Fixes: #17430 Reviewed-By: James M Snell <[email protected]>
MylesBorins commented Jan 22, 2018
should this be backported to v6.x or 8.x... my gut is no but not 100% |
MylesBorins commented Feb 27, 2018
ping re: backport |
MylesBorins commented May 22, 2018 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
ping re: backport edit: landed cleanly on 8.x. Any reason not to land? |
PR-URL: #17432Fixes: #17430 Reviewed-By: James M Snell <[email protected]>
TimothyGu commented May 23, 2018
@MylesBorins No, not really. |
PR-URL: #17432Fixes: #17430 Reviewed-By: James M Snell <[email protected]>
PR-URL: #17432Fixes: #17430 Reviewed-By: James M Snell <[email protected]>
Fixes: #17430
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
fs, src