-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
doesn't emit change
event when a watched folder is moved or deleted on Windows
#31702
Comments
Example const fs = require('fs')
if (!fs.existsSync('dir'))
fs.mkdirSync('dir')
fs.watch('./dir').on('error', console.log) then delete folder Error: EPERM: operation not permitted, watch
at FSEvent.FSWatcher._handle.onchange (internal/fs/watchers.js:123:28) {
errno: -4048,
syscall: 'watch',
code: 'EPERM',
filename: null
} in |
We can't do anything about the folder itself being changed. You can always watch the parent folder though. As for the I'll open a PR to add those two things to the "caveats" section of the |
Document Windows specific fs.watch caveats. Fixes: nodejs#31702
Document Windows specific fs.watch caveats. Fixes: #31702 PR-URL: #32176 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Masashi Hirano <shisama07@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Document Windows specific fs.watch caveats. Fixes: #31702 PR-URL: #32176 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Masashi Hirano <shisama07@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Document Windows specific fs.watch caveats. Fixes: #31702 PR-URL: #32176 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Masashi Hirano <shisama07@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Hello, hello! I'm back with another fs "bug"
On Linux (tested with Ubuntu 18.04 with the same NodeJS version), when you move or delete a folder watched by
fs.watch
, a thechange
event is emitted withchangeType
being"rename"
. However, on Windows, the following happens:error
is emitted with"Error: EPERM: operation not permitted, watch"
Sidenote: detecting folder deletions is unreliable in general as renaming a file/folder within the watched folder with the same name as the watched folder will emit the exact same event as the watched folder itself being renamed or deleted, on Linux anyway.
The text was updated successfully, but these errors were encountered: