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

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

Open
github0013 opened this issue Sep 10, 2021 · 5 comments

Comments

@github0013
Copy link

github0013 commented Sep 10, 2021

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)

@ColinDKelley
Copy link
Collaborator

One idea I'm considering is to make listen work optionally with the escalate gem. That gem provides a hook for escalating exceptions. I wouldn't want to have a hard dependency, but perhaps if it's been required by the time the listen code is running, it could use that hook.

@github0013 What do you think? If you could register an escalate callback to intercept these exceptions, would that do what you need?

@ColinDKelley
Copy link
Collaborator

@github0013 Any opinion here?

@ColinDKelley
Copy link
Collaborator

@github0013 Just checking in here. Any opinions above? Is this ticket is worth keeping open?

@github0013
Copy link
Author

@ColinDKelley

Sory I had been on a busy project, and I couldn't come back to github at all. Let me look into escalate gem and get back to you.

@ColinDKelley
Copy link
Collaborator

@github0013 Ok, thanks. And no pressure to use that gem! I'm open to any alternatives.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants