crystal-loot / selenium.cr

Selenium library for Crystal
https://crystal-loot.github.io/selenium.cr/
MIT License
24 stars 7 forks source link

Handle when underlying chromedriver process is closed #20

Open matthewmcgarvey opened 2 years ago

matthewmcgarvey commented 2 years ago

I was running a spec suite that used a mix of headless and non-headless specs. I think they use the same process so when the suite finished and it went through the drivers to close them, the first successfully closed the process but the next one raised an error.

Unhandled exception: Error connecting to 'localhost:9515': Connection refused (Socket::ConnectError)
  from /Users/matthew/.asdf/installs/crystal/0.36.1/src/socket/addrinfo.cr:73:15 in 'initialize'
  from /Users/matthew/.asdf/installs/crystal/0.36.1/src/socket/tcp_socket.cr:27:3 in 'new'
  from /Users/matthew/.asdf/installs/crystal/0.36.1/src/http/client.cr:779:5 in 'io'
  from /Users/matthew/.asdf/installs/crystal/0.36.1/src/http/client.cr:664:5 in 'send_request'
  from /Users/matthew/.asdf/installs/crystal/0.36.1/src/http/client.cr:599:5 in 'exec_internal_single'
  from /Users/matthew/.asdf/installs/crystal/0.36.1/src/http/client.cr:586:5 in 'exec_internal'
  from /Users/matthew/.asdf/installs/crystal/0.36.1/src/http/client.cr:581:7 in 'exec'
  from /Users/matthew/.asdf/installs/crystal/0.36.1/src/http/client.cr:706:5 in 'exec'
  from /Users/matthew/.asdf/installs/crystal/0.36.1/src/http/client.cr:738:7 in 'exec'
  from /Users/matthew/.asdf/installs/crystal/0.36.1/src/http/client.cr:406:3 in 'delete'
  from lib/selenium/src/selenium/http_client.cr:19:5 in 'delete'
  from lib/selenium/src/selenium/command_handler.cr:20:7 in 'execute'
  from lib/selenium/src/selenium/command_handler.cr:12:5 in 'execute'
  from lib/selenium/src/selenium/session.cr:30:5 in 'delete'
  from src/lucky_flow/driver.cr:17:20 in 'shutdown'
  from src/lucky_flow/registry.cr:18:38 in 'shutdown_all'
  from src/lucky_flow.cr:202:5 in 'shutdown'
  from spec/spec_helper.cr:29:3 in '->'
  from /Users/matthew/.asdf/installs/crystal/0.36.1/src/int.cr:541:7 in 'run_after_all_hooks'
  from /Users/matthew/.asdf/installs/crystal/0.36.1/src/spec/context.cr:19:7 in 'internal_run'
  from /Users/matthew/.asdf/installs/crystal/0.36.1/src/spec/context.cr:147:7 in 'run'
  from /Users/matthew/.asdf/installs/crystal/0.36.1/src/spec/dsl.cr:274:7 in '->'
  from /Users/matthew/.asdf/installs/crystal/0.36.1/src/primitives.cr:255:3 in 'run'
  from /Users/matthew/.asdf/installs/crystal/0.36.1/src/crystal/main.cr:45:14 in 'main'
  from /Users/matthew/.asdf/installs/crystal/0.36.1/src/crystal/main.cr:119:3 in 'main'
matthewmcgarvey commented 2 years ago

The error is pointing towards the more important issue of #21 but it still should not fail like this. If the process is dead, there's nothing to stop. Job done 🤷