Skip to content

Getting ERROR -- : Exception rescued in _process_changes: on an exception raise in the block #547

@github0013

Description

@github0013

I checked the issues, and I found this #535 . It should be the same error?

Environments

  • Linux 7b6db3dee39e 5.4.0-81-generic 91-Ubuntu SMP Thu Jul 15 19:09:17 UTC 2021 x86_64 Linux
  • ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux-musl]

Reproduction

Let this run.

Loading development environment (Rails 5.2.6)
[1] pry(main)> begin
  listener = Listen.to("/app") do |modified, added, removed|
    raise if added.size > 0
  end
  listener.start
  sleep
rescue => ex
  puts "rescued #{ex.message}"
ensure
  listener.stop
end

Then touch a file.

$ touch /app/file

And I get this in the console.

E, [2021-09-10T12:59:43.731341 #386] ERROR -- : Exception rescued in _process_changes:
RuntimeError:
(pry):3:in `block in <main>'
/usr/local/bundle/gems/listen-3.7.0/lib/listen/event/config.rb:28:in `call'
/usr/local/bundle/gems/listen-3.7.0/lib/listen/event/processor.rb:117:in `block in _process_changes'
/usr/local/bundle/gems/listen-3.7.0/lib/listen/thread.rb:26:in `rescue_and_log'
/usr/local/bundle/gems/listen-3.7.0/lib/listen/event/processor.rb:116:in `_process_changes'
/usr/local/bundle/gems/listen-3.7.0/lib/listen/event/processor.rb:25:in `block in loop_for'
/usr/local/bundle/gems/listen-3.7.0/lib/listen/event/processor.rb:20:in `loop'
/usr/local/bundle/gems/listen-3.7.0/lib/listen/event/processor.rb:20:in `loop_for'
/usr/local/bundle/gems/listen-3.7.0/lib/listen/event/loop.rb:85:in `_process_changes'
/usr/local/bundle/gems/listen-3.7.0/lib/listen/event/loop.rb:51:in `block in start'
/usr/local/bundle/gems/listen-3.7.0/lib/listen/thread.rb:26:in `rescue_and_log'
/usr/local/bundle/gems/listen-3.7.0/lib/listen/thread.rb:18:in `block in new'

I need to catch the exception the listen block raises, so I can safely stop the main thread, but it seems the runtime error is not rescuable as above. (not going through puts "rescued #{ex.message}" part)

I tried this #362 (comment) Thread.main.wakeup but it's only good when the main thread is sleeping. (if it's blocking by file access or whatnot, it doesn't work)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions