Description
So I have had this issue for a long time now. I am not versed in spring's internals, so I don't really know what is happening.
The issue is as follows :
- Boot spring server
- Run spring commands (rails c, rails g, rails migrate ...)
- After a while running any spring command will hang indefinitely.
- The server logs seem to indicate it's always after some watcher reload, but unsure why / if really related
Important note : I'm running 2 spring server in 2 different projects. For a while I was just running them normally, but I recently tried adding a separate SPRING_TMP_PATH
for each, hoping it would solve the issue but it didn't.
Also : Spring is NOT bundled in the project (but the project uses bundler). My other teammates don't want to use it, so I installed it myself locally gem install spring
and have aliases to run spring on rails
commands : alias rails=spring rails
Here are the server logs :
[2024-08-20 14:52:02 -0400] [64886] [server] running command rake
[2024-08-20 14:52:02 -0400] [65576] [client] waiting for the application to be preloaded
[2024-08-20 14:52:02 -0400] [64888] [application:development] got client
[2024-08-20 14:52:02 -0400] [65576] [client] app preload status: 0
[2024-08-20 14:52:02 -0400] [65576] [client] sending command
[2024-08-20 14:52:02 -0400] [64888] [application:development] forked 65577
[2024-08-20 14:52:02 -0400] [64886] [application_manager:development] got worker pid 65577
[2024-08-20 14:52:02 -0400] [65576] [client] got pid: 65577
[2024-08-20 14:52:07 -0400] [64888] [application:development] 65577 exited with 0
[2024-08-20 14:52:07 -0400] [65576] [client] got exit status 0
[2024-08-20 14:53:12 -0400] [64888] [watcher:development] check_stale: mtime=1724179281.6009805 < computed=1724179992.4119434
[2024-08-20 14:53:12 -0400] [64888] [watcher:development] marked stale, calling listeners: listeners=[#<Proc:0x000000011c8dca08 /Users/fmichaut/.rvm/gems/ruby-3.3.0/gems/spring-4.2.1/lib/spring/application.rb:75>]
[2024-08-20 14:53:12 -0400] [64888] [application:development] running -> watcher_stale
[2024-08-20 14:53:12 -0400] [64888] [application:development] watcher_stale -> exiting
[2024-08-20 14:53:35 -0400] [64886] [server] accepted client
[2024-08-20 14:53:35 -0400] [64886] [server] running command rails_generate
[2024-08-20 14:53:35 -0400] [65786] [client] waiting for the application to be preloaded
[2024-08-20 14:53:35 -0400] [64886] [application_manager:development] Invalid argument - sendmsg(2) while reading from child; returning no pid
[2024-08-20 14:54:00 -0400] [64886] [server] accepted client
[2024-08-20 14:54:00 -0400] [64886] [server] running command rails_console
[2024-08-20 14:54:00 -0400] [64886] [application_manager:development] Invalid argument - sendmsg(2) while reading from child; returning no pid
[2024-08-20 14:54:00 -0400] [65856] [client] waiting for the application to be preloaded
There is no more logs after this. You can see I attempted to run rails g
and rails c
-> both are waiting for application to be preloaded
indefinitively because of the sendmsg
error.
This effectively locks my terminal and I have to kill -9
the spring client process, CTRL-C is apparently ignored
The only fix I have found is to spring stop
and re-run the command