Comments (14)
I got this exception when running tests on CI (github actions):
⎯⎯⎯⎯ Unhandled Rejection ⎯⎯⎯⎯⎯
Error: EACCES: permission denied, watch '/tmp/snap.lxd'
❯ FSWatcher.<computed> node:internal/fs/watchers:244:19
❯ Object.watch node:fs:2315:34
❯ Watcher.watchDirectories node_modules/watcher/dist/watcher.js:192:40
❯ node_modules/watcher/dist/watcher.js:234:36
❯ async /home/runner/work/proj/proj/node_modules/watcher/dist/watcher.js:123:17
Btw, the workaround that @dividedmind mentioned works for me — just using:
const watcher = new Watcher(root, { ignore: (path) => !path.startsWith(root) });
from watcher.
from watcher.
@beorn One workaround is to use ignore
parameter:
const watcher = new Watcher(root, { ignore: (path) => !(path.startsWith(root) || root.startsWith(path)) });
This will skip examining everything with is not a direct ancestor or descendant of root
.
from watcher.
@dividedmind Thanks, that seems to work!
I got it working without root.startsWith(path)
— in which case is that needed?
from watcher.
@dividedmind Thanks, that seems to work!
I got it working without
root.startsWith(path)
— in which case is that needed?
Strange, for me it didn't work without this — it led to ignoring /tmp
and /
, pruning out the whole universe. Maybe because I used { recursive: true }
? Or maybe I'm misremembering. :)
from watcher.
I was also using { recursive: true }
... Hm... Maybe related to symbolic links or relative paths? 🤷
from watcher.
I was also using
{ recursive: true }
... Hm... Maybe related to symbolic links or relative paths? shrug
I might have been watching a root which didn't initially exist.
from watcher.
Not try to stat anything but the direct ancestors of the path you're in (so /tmp and /tmp/my-* only) - not all children of parent
That's necessary for the watcher to work correctly.
Provide a way to turn off parent watching
That would also cause bugs if turned off.
Gracefully handle these kinds of errors
Sure, I should probably add some tests for this use case. Was the watcher throwing or just emitting error events for you?
from watcher.
I can't reproduce the issue under macOS with this code:
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import Watcher from 'watcher';
const root = await fs.promises.mkdtemp(path.resolve(os.tmpdir(), "my-"));
const watcher = new Watcher(root);
@beorn can you reproduce the issue just with this? If so I'll test under my Linux VM.
from watcher.
I can't reproduce it under my linux VM either, maybe github actions are doing something weird, I'll look at that but low priority for now.
from watcher.
Hi, it seems like the snap.lxd
is a snap virtual disk, and maybe that's why you can't reproduce the error.
https://snapcraft.io/lxd
Regards.
from watcher.
Possibly, but I need to reproduce the issue, hopefully much more easily than using snap, to figure out how to fix it. I tried messing with permissions and stuff and I couldn't reproduce the issue.
from watcher.
Possibly, but I need to reproduce the issue, hopefully much more easily than using snap, to figure out how to fix it. I tried messing with permissions and stuff and I couldn't reproduce the issue.
Did you try creating something in /tmp
which is not accessible by the user before trying to reproduce? Ie. sudo mkdir /tmp/no-entry; sudo chmod 0700 /tmp/no-entry
.
from watcher.
I don't remember if in /tmp, but I did try to mess with permissions with no luck. If somebody can paste some code that reproduces the problem it'd be useful 👍
from watcher.
Related Issues (20)
- There is a typo in example. HOT 1
- filter metadata change HOT 1
- Opening a file triggers change HOT 1
- Watch network shares HOT 1
- How to make this package work in electron main processes? Enable the CommonJs Require HOT 1
- TypeError: Watcher is not a constructor HOT 1
- Wait writing files to finish HOT 1
- Watcher doesn't listening local disk such as Disk D on Windows
- Support for awaitWriteFinish HOT 1
- Error [ERR_REQUIRE_ESM]: require() of ES Module HOT 1
- Change of file not detected on macOS
- doc: Small update to `Comparison` documentation
- TypeScript issues HOT 9
- Bug: Recursive watcher with depth = 1 does not work under Linux if watched folder has subfolders HOT 1
- Issue with Docker (and Windows host) ? HOT 1
- Question: run once and stop watching? HOT 1
- Update versions of Node tested on CI HOT 3
- rename detection without timeout HOT 4
- Cannot use with Electron anymore HOT 2
- CommonJS HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from watcher.