chokidar watch fails

Created on 9 May 2015  路  11Comments  路  Source: paulmillr/chokidar

environment:

os: ubuntu 13.10
iojs: v1.8.1
chokidar:v1.0.1

erros

[2015-05-09 21:42:22.923] [ERROR] console -  Caught exception: SYSTEM_ERROR: watch ENOSPC
    at exports._errnoException (util.js:749:11)
    at FSWatcher.start (fs.js:1228:11)
    at Object.fs.watch (fs.js:1254:11)
    at createFsWatchInstance (/home/xxx/node_modules/chokidar/lib/nodefs-handler.js:37:15)
    at setFsWatchListener (/home/xxx/node_modules/chokidar/lib/nodefs-handler.js:80:19)
    at EventEmitter.NodeFsHandler._watchWithNodeFs (/home/xxx/node_modules/chokidar/lib/nodefs-handler.js:228:14)
    at EventEmitter.NodeFsHandler._handleDir (/home/xxx/node_modules/chokidar/lib/nodefs-handler.js:403:23)
    at EventEmitter.<anonymous> (/home/xxx/node_modules/chokidar/lib/nodefs-handler.js:450:19)
    at EventEmitter.<anonymous> (/home/xxx/node_modules/chokidar/lib/nodefs-handler.js:455:16)
    at FSReqWrap.oncomplete (fs.js:78:15)

Most helpful comment

@jhartma
i close the sublime or remove some project and it works.
may be there are some many files need to watch when sublime open a lot files.

ENOSPC can also mean you're running into one of the system limits:

$ sysctl -a | grep ^fs.inotify
fs.inotify.max_queued_events = 16384
fs.inotify.max_user_instances = 128
fs.inotify.max_user_watches = 8192

All 11 comments

ENOSPC means that there is no space on the drive. Is that the case?

it is impossible of that case!

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       144G   50G   88G  37% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
udev            1.5G  4.0K  1.5G   1% /dev
tmpfs           295M  1.2M  293M   1% /run
none            5.0M     0  5.0M   0% /run/lock
none            1.5G   17M  1.5G   2% /run/shm
none            100M   44K  100M   1% /run/user

maybe it is the memory space issue.

weird, same problem here, restart helped

@jhartma
i close the sublime or remove some project and it works.
may be there are some many files need to watch when sublime open a lot files.

ENOSPC can also mean you're running into one of the system limits:

$ sysctl -a | grep ^fs.inotify
fs.inotify.max_queued_events = 16384
fs.inotify.max_user_instances = 128
fs.inotify.max_user_watches = 8192

I have same problems due to system limitation. I would like only watch directory and I wonder why chokidar add watch on every file in directory ? So if I put more than max_user_watches application crash with ENOSPC. I could do workaround. But I would like to know if it is possible to watch only directory ?

why chokidar add watch on every file in directory

because that's the only way to reliably detect all the changes

if it is possible to watch only directory

Not with chokidar. If you only want a watcher at the directory level only, use fs.watch directly.

So fix is to always try to use relative/absolute paths for globs.
For example __dirname, cwd or just prepending the glob with ./, e.g. ./dir/*.{js,css,html}.

why chokidar add watch on every file in directory

because that's the only way to reliably detect all the changes

Hi @es128, are you sure watching individual files is needed on Linux? If so, can you share the issues you've come across?

My experience with file watching on Linux, Mac & Windows is that Linux is the only OS with a completely reliable file watching sub-system, and doesn't need a helping hand over and above the fact that it doesn't support recursive directory watches, so that you have to add and remove shallow directory watches on the fly as directories come into and go out of existence.

The only real downside to Linux's file watching that I've run into is that you can easily run out of watch handles, and so watching files rather than directories (which will only exacerbate this problem) would definitely be a good one to avoid if at all possible.

You will miss change events if you watch only the directory and not the files (depending on how the file was modified). If you only care about files being created, deleted, or moved, then yes, directory-level watchers should suffice. But chokidar does not provide an option for this.

Hi @es128, are you sure that's the case for Linux too, or is it a design of lowest common denominator?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

paulmillr picture paulmillr  路  4Comments

nikoladev picture nikoladev  路  6Comments

bnainar picture bnainar  路  7Comments

ahmadnassri picture ahmadnassri  路  6Comments

RedMickey picture RedMickey  路  4Comments