-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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.watch throws exception when recursive is used in incompatible platform #29947
Conversation
f39ce99
to
76c5f11
Compare
Okay I had to alter the first commit so it will be compatible to the format of the project. I believe that the PR is ready now. |
The PR has a bit changed, it now uses a new more generic error, |
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.
Left some comments. Thanks for the PR!
lib/internal/errors.js
Outdated
E('ERR_FEATURE_UNAVAILABLE_ON_PLATFORM', | ||
(feature) => 'The feature ' + feature + | ||
' is unavailable on the current platform' + | ||
', which is being used to run Node.js', TypeError); |
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.
Nit: this could be simplified as:
E('ERR_FEATURE_UNAVAILABLE_ON_PLATFORM',
'The feature %s is unavailable on the current platform' +
', which is being used to run Node.js',
TypeError);
(It's a semi standard to use that pattern if the error is not too complex)
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 with the comments incorporated.
I switched from try and catch to built in function & extracted the old logic so it will be more neat. I also reformatted the errors. |
Still LGTM |
@nodejs/tsc |
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
doc/api/errors.md
Outdated
@@ -2352,6 +2352,12 @@ The `--entry-type=...` flag is not compatible with the Node.js REPL. | |||
Used when an [ES Module][] loader hook specifies `format: 'dynamic'` but does | |||
not provide a `dynamicInstantiate` hook. | |||
|
|||
<a id="ERR_FEATURE_UNAVAILABLE_ON_PLATFORM"></a> | |||
#### ERR_FEATURE_UNAVAILABLE_ON_PLATFORM |
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.
Just a nit... I would just make this more generic like ERR_NOT_IMPLEMENTED
or ERR_NOT_AVAILABLE
, but it's not critical
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 think there is a great value of knowing this error occurs only on one platform, and that it isn't something that node.js itself doesn't support.
ok I can see that some tests fail. Can I contribute to fix it? |
@exx8 Sorry, it’s been a while and the old CI results are no longer available. I’ve started a new one, though. Generally, feel free to ping us if you feel like a PR is stalling out somehow. |
It seems that there is a merge conflict now (according to the build:
) or it might be a false alarm (as github says there aren't). |
I think the issue is that one of the 14 commits in this PR has a merge conflict, but not the PR as a whole (i.e. one of the later commits removed the merge conflict again).
It would be helpful if you could rebase this (not
If the contents of the PR stay the same apart from resolving merge conflicts, that should be okay. |
Co-Authored-By: Ben Noordhuis <info@bnoordhuis.nl>
Co-Authored-By: Ben Noordhuis <info@bnoordhuis.nl>
Co-Authored-By: Ben Noordhuis <info@bnoordhuis.nl>
Rebased to eliminate conflict. |
This comment has been minimized.
This comment has been minimized.
@Trott seems like there's a linter issue now? |
This pull request makes fs.watch throw exception, whenever it is used in an incompatible platform. For this change following changes were made to api: 1.a new error type has been introduced. 2.fs.watch has been changed accordingly. Users who use recursive on non-windows and osx platforms, will face a new exception. For this reason, it's a breaking change. Fixes: #29901 PR-URL: #29947 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Landed in 67e067e. Thanks for the contribution! 🎉 |
This makes sure this function stays backwards compatible in case it's accessed through the binding directly. Refs: #29947 (comment) Backport-PR-URL: #31431 PR-URL: #30858 Refs: #30767 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This makes sure this function stays backwards compatible in case it's accessed through the binding directly. Refs: #29947 (comment) Backport-PR-URL: #31431 PR-URL: #30858 Refs: #30767 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Use `chokidar` to track file system changes as soon it will throw an error if the platform does not support `{ recursive: true }`. Fix also an error where the built file was not being deleted when the source was removed. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Fix react-native-community#989 Ref: nodejs/node#29947
Use `chokidar` to track file system changes as soon it will throw an error if the platform does not support `{ recursive: true }`. Fix also an error where the built file was not being deleted when the source was removed. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Fix react-native-community#989 Ref: nodejs/node#29947
Use `chokidar` to track file system changes as soon it will throw an error if the platform does not support `{ recursive: true }`. Fix also an error where the built file was not being deleted when the source was removed. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Fix #989 Ref: nodejs/node#29947
This pull request makes fs.watch throw exception whenever it is used in an incompatible platform.
For this change following changes were made to api:
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesSolves #29901
This is a breaking change.