Skip to content
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

Error: cannot send event from fs watcher: no available capacity #241

Open
bruceg opened this issue Jan 24, 2022 · 10 comments
Open

Error: cannot send event from fs watcher: no available capacity #241

bruceg opened this issue Jan 24, 2022 · 10 comments
Labels
bug Something's not right! improvement Making an existing feature better, rather than a new one
Milestone

Comments

@bruceg
Copy link
Contributor

bruceg commented Jan 24, 2022

Running watchexec version 1.18.0 through 1.18.2 prints out the following line hundreds of times when the subprogram modifies files.

[[cannot send event from fs watcher: no available capacity]]

When this happens, I am unable to stop watchexec from the terminal using Control-C or with kill (SIGTERM). Only kill -KILL works to stop it.

Version 1.17.1 and earlier do not exhibit this behavior.

I am currently using this with watchexec --debounce 500 -- cargo check --workspace … (yes, I am aware of cargo watch but the cargo check was actually part of a script that does a couple other non-cargo checks)

@passcod
Copy link
Member

passcod commented Jan 24, 2022

(you can still use cargo watch, eg with -s)

What OS is this? What are you watching?

I've got a remediation in mind, I'll see what I can do tonight

@bruceg
Copy link
Contributor Author

bruceg commented Jan 24, 2022

This is Arch Linux, kernel version 5.16.2. I am running this in the Vector source tree.

@passcod
Copy link
Member

passcod commented Jan 25, 2022

I know this makes 1.18 useless for you, and I'm sorry for that, but I've got no bandwidth for the proper fix tonight and possibly the rest of the week; I'll try to get to it this weekend.

This is related to #227.

@passcod passcod added bug Something's not right! improvement Making an existing feature better, rather than a new one labels Jan 25, 2022
@passcod passcod added this to the 1.18 issues milestone Jan 26, 2022
@passcod
Copy link
Member

passcod commented Jan 30, 2022

While the root cause isn't yet fixed, 1.18.5 includes a fix which should help by relieving the pressure on the event channel.

@Mange
Copy link
Contributor

Mange commented Feb 2, 2022

How can I use #227 (I meant #254) to get around this? I can't figure it out.

It seems to me that there's a leak of inotify watchers, or too many watchers are set up.

> fd '.*\.rb' | wc -l
1032
> watchexec -e rb -- sleep 1
./bin/inotify-consumers

   INOTIFY
   WATCHES
    COUNT     PID USER     COMMAND
--------------------------------------
   35788   750356 mange    watchexec -e rb -- sleep 1

Is it walking down into my .git directory? It's not as easy as it watching all files recursively either.

> find . -type f | wc -l
89125

@passcod
Copy link
Member

passcod commented Feb 2, 2022

Yes, exactly so, it's recursing down every subdirectory regardless of them being ignored. 1.18.5 made that less likely to overwhelm the loop. #245 will add library capability to ignore or filter subdirectories, which could be used in the future to provide the direct control #227 wants, and will be used presently to stop recursing down paths which are ignored (including .git, output folders, etc).

As to your counts: try with the number of directories only? With inotify, that's what is watched.

@mikepqr
Copy link

mikepqr commented Feb 11, 2022

My use case is a home directory containing a small number of directories and files that I do want to watch and a monorepo with hundreds of thousands of files that I do not want to watch.

Am I right in thinking this is not currently performant in watchexec because it sets up OS-level watchers on all files below the root, and filters out events on ignored paths as a post-processessing step, but that once #245 lands this use case will work well.

Is that about right? :-) (Happy to open a new issue for my use case if I've misunderstood this one!)

@passcod
Copy link
Member

passcod commented Feb 12, 2022

That's exactly right! You can do what you want with manual applications of -w for now, though.

@mikepqr
Copy link

mikepqr commented Feb 12, 2022

Thanks! Looking forward to #245, because I don't think I can using -w is going to work for me. Please correct me if I'm wrong!

Essentially I have a tree that looks like this when I launch watchexec

.
├── bar/
├── foo.txt
└── ignoreme/
    └── baz.txt and 1000000s more files

I can't watch ignoreme/ (even if I discard the events), so I can't watch .. And a new directory might be created next to bar/ while watchexec is running, so enumerating the directories to watch with -w seems like it's not going to work.

@passcod
Copy link
Member

passcod commented Feb 12, 2022

Right, in this case, you can't use -w but #245 will work.

@passcod passcod modified the milestones: 1.18 issues, 1.19 issues Apr 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something's not right! improvement Making an existing feature better, rather than a new one
Projects
None yet
Development

No branches or pull requests

4 participants