rubycdp / ferrum

Headless Chrome Ruby API
https://ferrum.rubycdp.com
MIT License
1.69k stars 120 forks source link

Cannot call `exit` from within `.on()` blocks #395

Closed postmodern closed 6 months ago

postmodern commented 10 months ago

When I call exit from within an browser.on(...) { ... } block, it generates a weird logging error message instead of exiting. I suspect somewhere in Ferrum it is trying to rescue SystemExit as an error.

Example Code

require 'ferrum'

browser = Ferrum::Browser.new
browser.network.intercept
browser.on(:request) do
  exit
end

browser.go_to('https://example.com')
sleep

Expected Result

Exits the script

Actual Result

2023-08-28 04:52:02.989] ERROR -- exit: nil

Version Info

route commented 8 months ago

on is happening in another thread, so this might need a documentation and investigation.

route commented 8 months ago

I think this is connected to https://github.com/rubycdp/ferrum/issues/396