spring icon indicating copy to clipboard operation
spring copied to clipboard

Client timeout causes server crash

Open f1sherman opened this issue 1 year ago • 1 comments

I noticed recently that when a Spring client times out, that it also crashes the server. This appears to be because the server tries to write to the client and gets a Broken pipe error. In this case I would expect the server to remain up. I can reproduce this pretty easily by sending 2 concurrent commands to the Spring server.

Client:

/app/vendor/bundle/ruby/3.3.0/gems/spring-4.2.1/lib/spring/client/run.rb:124:in `verify_server_version': Error connecting to Spring server (RuntimeError)
        from /app/vendor/bundle/ruby/3.3.0/gems/spring-4.2.1/lib/spring/client/run.rb:60:in `run'
        from /app/vendor/bundle/ruby/3.3.0/gems/spring-4.2.1/lib/spring/client/run.rb:40:in `warm_run'
        from /app/vendor/bundle/ruby/3.3.0/gems/spring-4.2.1/lib/spring/client/run.rb:33:in `call'
        from /app/vendor/bundle/ruby/3.3.0/gems/spring-4.2.1/lib/spring/client/command.rb:7:in `call'
        from /app/vendor/bundle/ruby/3.3.0/gems/spring-4.2.1/lib/spring/client/rails.rb:22:in `call'
        from /app/vendor/bundle/ruby/3.3.0/gems/spring-4.2.1/lib/spring/client/command.rb:7:in `call'
        from /app/vendor/bundle/ruby/3.3.0/gems/spring-4.2.1/lib/spring/client.rb:30:in `run'
        from /app/vendor/bundle/ruby/3.3.0/gems/spring-4.2.1/bin/spring:49:in `<top (required)>'

Server:

[2024-08-02 21:13:08 +0000] [1] [application_manager:development] got worker pid 287
[2024-08-02 21:13:08 +0000] [198] [client] got pid: 287
[2024-08-02 21:13:08 +0000] [1] [server] accepted client
[2024-08-02 21:13:08 +0000] [1] [server] shutting down
[2024-08-02 21:13:08 +0000] [1] [application_manager:development] stopping
[2024-08-02 21:13:08 +0000] [207] [application:development] running -> terminating
[2024-08-02 21:13:08 +0000] [207] [application:development] terminating -> exiting
[2024-08-02 21:13:09 +0000] [207] [application:development] 287 exited with 0
[2024-08-02 21:13:09 +0000] [198] [client] got exit status 0
/app/vendor/bundle/ruby/3.3.0/gems/spring-4.2.1/lib/spring/server.rb:57:in `write': Broken pipe (Errno::EPIPE)
        from /app/vendor/bundle/ruby/3.3.0/gems/spring-4.2.1/lib/spring/server.rb:57:in `puts'
        from /app/vendor/bundle/ruby/3.3.0/gems/spring-4.2.1/lib/spring/server.rb:57:in `serve'

f1sherman avatar Aug 02 '24 21:08 f1sherman

@f1sherman I believe I’m encountering the same issue. Jenkins crashes unexpectedly after upgrading Spring from version 2.1.1 to 4.2.1.

is it safe to patch Spring using this change https://github.com/rails/spring/pull/725 ?

rvalladares77 avatar Jan 16 '25 00:01 rvalladares77