dunglas / go-fswatch

Go bindings for libfswatch
https://dunglas.dev
BSD 3-Clause "New" or "Revised" License
18 stars 0 forks source link

"an unknown error has occurred" fsnotify with too many files #9

Closed AlliBalliBaba closed 2 months ago

AlliBalliBaba commented 2 months ago

On linux with fsnotify session.Start() returned the error "an unknown error has occurred".

This happens only when watching more than 12.000+ files. I'm pretty sure the error comes from some kind of system file limit (I'm in the frankenphp-dev Docker on Ubuntu WSL) Still it would be nice to get a proper error message if that's even possible.

dunglas commented 2 months ago

For the record, using sysctl fs.inotify.max_user_watches <number> should allow increasing the limit.

I'm not sure how we can catch this error. If it's possible at all, this should likely by done in the underlying C++ library.

Maybe could we just document this behavior?

AlliBalliBaba commented 2 months ago

I guess we can document it, I'll add a warning. Btw: when trying to call Session.Destroy(), I'm sometimes seeing this error: a monitor is already running in the specified session

Is there a necessary grace period between calling Session.Stop() and Session.Destroy()? Don't know if it's safe to ignore the error.

dunglas commented 2 months ago

Yes, it looks like the grace period is mandatory, even in the C++ test suite they add a sleep().