guard / listen

The Listen gem listens to file modifications and notifies you about the changes.
https://rubygems.org/gems/listen
MIT License
1.91k stars 245 forks source link

`synchronize': can't be called from trap context (ThreadError) #565

Open aaronjensen opened 1 year ago

aaronjensen commented 1 year ago

This particular warning happens in a Rails app when using Puma. I don't know that there is anything that Puma or Rails can do differently here to prevent this from happening, but I will report it in Rails as well (perhaps stopping listener in a finalizer is just wrong because of this). I believe it's happening when Puma is stopping a thread and a GC happens. The rest of the stack trace was application code, so it was clearly a signal.

my-app/gems/ruby/3.1.0/gems/actionview-7.0.4/lib/action_view/helpers/tag_helper.rb:189: warning: Exception in finalizer #<Proc:0x000000010852fb80 my-app/gems/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/evented_file_update_checker.rb:91>
my-app/gems/ruby/3.1.0/gems/listen-3.7.1/lib/listen/fsm.rb:80:in `synchronize': can't be called from trap context (ThreadError)
        from my-app/gems/ruby/3.1.0/gems/listen-3.7.1/lib/listen/fsm.rb:80:in `transition!'
        from my-app/gems/ruby/3.1.0/gems/listen-3.7.1/lib/listen/fsm.rb:104:in `transition_with_callbacks!'
        from my-app/gems/ruby/3.1.0/gems/listen-3.7.1/lib/listen/fsm.rb:72:in `transition'
        from my-app/gems/ruby/3.1.0/gems/listen-3.7.1/lib/listen/listener.rb:103:in `stop'
        from my-app/gems/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/evented_file_update_checker.rb:111:in `stop'
        from my-app/gems/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/evented_file_update_checker.rb:92:in `block in finalizer'