Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.3k
fs: add recursive watch for linux#45098
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.
Changes from all commits
cdc9349296646b77cb9a05b7244987866c300ab12dcb4b45541449499a864108b3654189abb18f15251fcd240a66311cf5d8d2a0c632a4bcdf610ef8243dde37a0839c7512ef6eee878a6906f260613309d596e8d94f365b5161e56e4299d2e5d4b3cd3199bd69a56528ee3878e4e3dde6019be1e903a2b8b87f6ab4f1d2c11bb62bddb83fFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -4320,6 +4320,9 @@ The `atime` and `mtime` arguments follow these rules: | ||
| <!-- YAML | ||
| added: v0.5.10 | ||
| changes: | ||
| - version: REPLACEME | ||
| pr-url: https://github.com/nodejs/node/pull/45098 | ||
| description: Added recursive support for Linux, AIX and IBMi. | ||
| - version: | ||
| - v15.9.0 | ||
| - v14.17.0 | ||
| @@ -4377,10 +4380,6 @@ the returned{fs.FSWatcher}. | ||
| The `fs.watch` API is not 100% consistent across platforms, and is | ||
| unavailable in some situations. | ||
| The recursive option is only supported on macOS and Windows. | ||
| An `ERR_FEATURE_UNAVAILABLE_ON_PLATFORM` exception will be thrown | ||
| when the option is used on a platform that does not support it. | ||
anonrig marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. | ||
| On Windows, no events will be emitted if the watched directory is moved or | ||
| renamed. An `EPERM` error is reported when the watched directory is deleted. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -57,6 +57,7 @@ const{ | ||
| const pathModule = require('path'); | ||
| const{isArrayBufferView } = require('internal/util/types'); | ||
| const nonNativeWatcher = require('internal/fs/recursive_watch'); | ||
| // We need to get the statValues from the binding at the callsite since | ||
| // it's re-initialized after deserialization. | ||
| @@ -68,7 +69,6 @@ const{ | ||
| codes:{ | ||
| ERR_FS_FILE_TOO_LARGE, | ||
| ERR_INVALID_ARG_VALUE, | ||
| ERR_FEATURE_UNAVAILABLE_ON_PLATFORM, | ||
| }, | ||
| AbortError, | ||
| uvErrmapGet, | ||
| @@ -163,7 +163,6 @@ let FileWriteStream; | ||
| const isWindows = process.platform === 'win32' | ||
| const isOSX = process.platform === 'darwin' | ||
anonrig marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. | ||
| function showTruncateDeprecation(){ | ||
| if (truncateWarn){ | ||
| process.emitWarning( | ||
| @@ -2297,13 +2296,22 @@ function watch(filename, options, listener){ | ||
| if (options.persistent === undefined) options.persistent = true; | ||
| if (options.recursive === undefined) options.recursive = false; | ||
| if (options.recursive && !(isOSX || isWindows)) | ||
| throw new ERR_FEATURE_UNAVAILABLE_ON_PLATFORM('watch recursively'); | ||
| const watcher = new watchers.FSWatcher(); | ||
| watcher[watchers.kFSWatchStart](filename, | ||
| options.persistent, | ||
| options.recursive, | ||
| options.encoding); | ||
| let watcher; | ||
| // TODO(anonrig): Remove this when/if libuv supports it. | ||
anonrig marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. | ||
| // As of November 2022, libuv does not support recursive file watch on all platforms, | ||
| // e.g. Linux due to the limitations of inotify. | ||
| if (options.recursive && !isOSX && !isWindows){ | ||
| watcher = new nonNativeWatcher.FSWatcher(options); | ||
| watcher[watchers.kFSWatchStart](filename); | ||
| } else{ | ||
| watcher = new watchers.FSWatcher(); | ||
| watcher[watchers.kFSWatchStart](filename, | ||
| options.persistent, | ||
| options.recursive, | ||
| options.encoding); | ||
| } | ||
| if (listener){ | ||
| watcher.addListener('change', listener); | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
Is it still true that it is unavailable in some situations?
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.
IBMi and AIX does not fully support
fs.watchThere 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.
As a task for later (follow on PR) it would be good to explain a bit more what "situations" it is unavailable.