Skip to content
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: improve errors from watch, watchFile and unwatchFile #19345

Closed
wants to merge 2 commits into from

Conversation

joyeecheung
Copy link
Member

fs: remove watcher state errors for fs.watch

  • Remove ERR_FS_WATCHER_ALREADY_STARTED and
    ERR_FS_WATCHER_NOT_STARTED because those two situations should
    result in noop instead of errors for consistency with the
    documented behavior of fs.watchFile.
    This partially reverts fs: improve errors thrown from fs.watch() #19089
  • Update comments about this behavior.

Refs: #19089

fs: improve errors in watchFile and unwatchFile

  • Check if the watcher is active in JS land before
    invoking the binding, act as a noop if the state of
    the watcher does not match the expectation. This
    avoids firing 'stop' when the watcher is already
    stopped.
  • Update comments, validate more arguments and
    the type of the handle.
  • Handle the errors from uv_fs_poll_start
  • Create an IsActive helper method on StatWatcher
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

- Remove ERR_FS_WATCHER_ALREADY_STARTED and
  ERR_FS_WATCHER_NOT_STARTED because those two situations should
  result in noop instead of errors for consistency with the
  documented behavior of fs.watchFile.
  This partially reverts nodejs#19089
- Update comments about this behavior.

Refs: nodejs#19089
- Check if the watcher is active in JS land before
  invoking the binding, act as a noop if the state of
  the watcher does not match the expectation. This
  avoids firing 'stop' when the watcher is already
  stopped.
- Update comments, validate more arguments and
  the type of the handle.
- Handle the errors from uv_fs_poll_start
- Create an `IsActive` helper method on StatWatcher
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. labels Mar 14, 2018
@joyeecheung joyeecheung added fs Issues and PRs related to the fs subsystem / file system. semver-major PRs that contain breaking changes and should be released in the next major version. labels Mar 14, 2018
@joyeecheung
Copy link
Member Author

CI: https://ci.nodejs.org/job/node-test-pull-request/13675/

cc @nodejs/tsc this is semver-major because of the additional throw. Please review, thanks!

@joyeecheung joyeecheung added the errors Issues and PRs related to JavaScript errors originated in Node.js core. label Mar 14, 2018
@joyeecheung
Copy link
Member Author

@nodejs/tsc this needs one more approval to land..thanks!

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@joyeecheung
Copy link
Member Author

@joyeecheung
Copy link
Member Author

Landed in 897cec4...897f7b6, thanks!

joyeecheung added a commit that referenced this pull request Mar 18, 2018
- Remove ERR_FS_WATCHER_ALREADY_STARTED and
  ERR_FS_WATCHER_NOT_STARTED because those two situations should
  result in noop instead of errors for consistency with the
  documented behavior of fs.watchFile.
  This partially reverts #19089
- Update comments about this behavior.

Refs: #19089

PR-URL: #19345
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
joyeecheung added a commit that referenced this pull request Mar 18, 2018
- Check if the watcher is active in JS land before
  invoking the binding, act as a noop if the state of
  the watcher does not match the expectation. This
  avoids firing 'stop' when the watcher is already
  stopped.
- Update comments, validate more arguments and
  the type of the handle.
- Handle the errors from uv_fs_poll_start
- Create an `IsActive` helper method on StatWatcher

PR-URL: #19345
Refs: #19089
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. errors Issues and PRs related to JavaScript errors originated in Node.js core. fs Issues and PRs related to the fs subsystem / file system. lib / src Issues and PRs related to general changes in the lib or src directory. semver-major PRs that contain breaking changes and should be released in the next major version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants