fs: migrate fs_event_wrap to internal/errors#17851
fs: migrate fs_event_wrap to internal/errors#17851maclover7 wants to merge 1 commit intonodejs:masterfrom maclover7:jm-fsevent-error
Conversation
|
ping @TimothyGu |
|
@maclover7 #17682 landed. Can you please rebase? |
|
updated @targos |
test/parallel/test-fs-watch.js
Outdated
There was a problem hiding this comment.
this is not the same, why this change?
It seems we are not exposing start at all, see https://nodejs.org/api/fs.html#fs_class_fs_fswatcher.
I think we should add it to the docs.
There was a problem hiding this comment.
Looks like this should be watcher.start(testCase[testCase.field])?
There was a problem hiding this comment.
There was a problem hiding this comment.
Umm, looking more closely I think .start() is accepted the second time it is called (i.e. the wrap is already initialized to watch on a file), so in JS land we should check if the wrap is initialized before calling validatePath(). The easiest way to do it is to store a field in the FSWatcher.prototype.start() in JS land, echoing what's being done in the C++ land (it also needs to be updated in .close())
There was a problem hiding this comment.
Or, if we don't want to return silently when someone tries to call .start() again on the initialized watcher:
if (!isInitialized) {
validatePath(filename);
} else {
throw errors.Error('ERR_FS_EVENT_STARTED'); // A new Error indicating this has been started.
}If we don't even want to document .start(), we can just assert(isInitialized) instead of creating a public error for it.
mhdawson
left a comment
There was a problem hiding this comment.
LGTM once comment about watcher.start() is addressed.
|
updated @joyeecheung PTAL |
| function FSWatcher() { | ||
| EventEmitter.call(this); | ||
|
|
||
| this._initialized = false; |
There was a problem hiding this comment.
Can you add a comment here mentioning that this should be kept in sync with the initialized field of the C++ wrap? (Arguably better if this is an accessor property on the prototype of FSWatcher, that way there is no need to set this field in start and close, although that brings a few more calls into C++ so I am fine with this as well)
|
@maclover7 would you be so kind and rebase and also address the comment? |
|
Ping @maclover7 |
|
Closing due to no further progress. @maclover7 please feel free to reopen in case you would like to continue working on this. |
Migrates
fs_event_wrap.ccto internal/errors style.Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
fs