Giter Site home page Giter Site logo

Comments (14)

beorn avatar beorn commented on August 25, 2024 1

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.

beorn avatar beorn commented on August 25, 2024 1

from watcher.

dividedmind avatar dividedmind commented on August 25, 2024

@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.

beorn avatar beorn commented on August 25, 2024

@dividedmind Thanks, that seems to work!

I got it working without root.startsWith(path) — in which case is that needed?

from watcher.

dividedmind avatar dividedmind commented on August 25, 2024

@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.

beorn avatar beorn commented on August 25, 2024

I was also using { recursive: true }... Hm... Maybe related to symbolic links or relative paths? 🤷

from watcher.

dividedmind avatar dividedmind commented on August 25, 2024

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.

fabiospampinato avatar fabiospampinato commented on August 25, 2024

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.

fabiospampinato avatar fabiospampinato commented on August 25, 2024

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.

fabiospampinato avatar fabiospampinato commented on August 25, 2024

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.

chumager avatar chumager commented on August 25, 2024

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.

fabiospampinato avatar fabiospampinato commented on August 25, 2024

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.

dividedmind avatar dividedmind commented on August 25, 2024

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.

fabiospampinato avatar fabiospampinato commented on August 25, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.