Uh oh!
There was an error while loading. Please reload this page.
src: make FSEventWrap/StatWatcher::Start more robust - #17432
Conversation
TimothyGu
commented
Dec 3, 2017
There was a problem hiding this comment.
For consistency with the surrounding code, maybe write this as return args.GetReturnValue().Set(0); without braces.
There was a problem hiding this comment.
Doesn't the linter complain about using two spaces before //?
There was a problem hiding this comment.
No it doesn't, though fixed anyway.
There was a problem hiding this comment.
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.
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.
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.
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.
What do you mean? There are no compatibility issues because it was aborting before.
There was a problem hiding this comment.
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.
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 <jasnell@gmail.com>
addaleax
commented
Dec 13, 2017
Landed in cd71fc1 |
bnoordhuis
commented
Dec 13, 2017
#17432 (comment) is still unfixed. |
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 |
ping re: backport edit: landed cleanly on 8.x. Any reason not to land? |
TimothyGu
commented
May 23, 2018
@MylesBorins No, not really. |
Fixes: #17430
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
fs, src