rails / spring

Rails application preloader
MIT License
2.81k stars 341 forks source link

Add timeout when connecting to server #708

Closed technicalpickles closed 11 months ago

technicalpickles commented 11 months ago

Over on https://github.com/rails/spring/issues/663 we've seen the spring server get into a funky state, where the server.gets just hangs indefinitely.

I found other places in client.rb that checked that there was something to read before reading, and made sure server.gets returns something. So, applied that to verify_server_version 😁

technicalpickles commented 11 months ago

I tested this two ways:

  1. bin/spring start in one console. background it, and run bin/rails console (or any other binstub)
  2. socat unix-listen:tmp/spring.sock /dev/null in one console. set SPRING_PIDFILE=tmp/spring.pid SPRING_SOCKET=tmp/spring.sock, and add the socat pid to tmp/spring.sock

In both, the binstub raises an error as expected.

casperisfine commented 11 months ago

cc @byroot

technicalpickles commented 11 months ago

Thank you! I'll be testing this on our app, and I'm hoping it will help surface when https://github.com/rails/spring/issues/663 happens