guard / rb-inotify

A thorough inotify wrapper for Ruby using FFI.
MIT License
312 stars 64 forks source link

inotify event queue has overflowed #111

Closed taq closed 1 month ago

taq commented 1 month ago

How can I solve an error like this:

E, [2024-09-17T16:27:40.351586 #241921] ERROR -- : Exception rescued in listen-run_thread::00:07                        
INotify::QueueOverflowError: inotify event queue has overflowed.                                                        
/home/taq/.rvm/gems/ruby-3.3.0/gems/rb-inotify-0.11.1/lib/rb-inotify/event.rb:120:in `initialize'     

I got this using guard after some tests run and then it stops untill I ask to run it again, not allowing to fire the tests as soon as the files involved change.

ioquatix commented 1 month ago

It means too many events happened between reading from the inotify queue, and thus it overflowed. Maybe try monitoring less things.

taq commented 1 month ago

Hey @ioquatix , thanks for your answer. The weird part is that everything was working fine till some weeks ago. Maybe a new Ubuntu version with new libs or updated some libs on the project may affected it? Or even the number of files on the project?

taq commented 1 month ago

@ioquatix is there a way to prevent to don't raise an exception and avoid keep listening to changes?

ioquatix commented 1 month ago

I don't think it's possible given the implementation:

https://github.com/guard/rb-inotify/blob/af800fb58fa3d5f77da74a46d9150f749c8bec4c/lib/rb-inotify/notifier.rb#L281-L307

It could be due to the number of files on your project and what you are monitoring. When the overflow occurs, the state of the file system becomes unknown, so you need to scan it again.

Instead of monitoring individual files, you could try https://github.com/socketry/io-watch which monitors only the directories. This reduces the number of events being generated.

taq commented 1 month ago

Will check the number of files tomorrow and give a feedback here.

taq commented 1 month ago

Hey @ioquatix seems that the culprit was simplecov. After I got this tip about the number of files (and yes, the project files increased on the last weeks) I notice simplecov was running also when there was a file change (the correct and expected behaviour) and tried to comment it, it seemed to work! No more overflows till now. Sorry to open this issue here, but at least I got a good tip about how things are working there. :-) Closing it.