From dca14de5508ef62f33caac7ee80c29d52622d418 Mon Sep 17 00:00:00 2001 From: Matt Rohrer Date: Thu, 12 Sep 2024 11:09:09 +0200 Subject: [PATCH] Prevent server crash by restarting child Before this change, if Errno::EINVAL is thrown when sending IO to the child the server would crash. Now we catch the exception and, assuming the child has problems, we start a new child. --- CHANGELOG.md | 2 ++ lib/spring/application_manager.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ccacc975..3de0ed8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## Next Release +* Fixed a bug that would crash the server if sending IO to the child failed + ## 4.2.1 * Added `Spring.connect_timeout` and `Spring.boot_timeout` to allow to increase timeout for larger apps. diff --git a/lib/spring/application_manager.rb b/lib/spring/application_manager.rb index 34c14dac..3b0d20b3 100644 --- a/lib/spring/application_manager.rb +++ b/lib/spring/application_manager.rb @@ -42,7 +42,7 @@ def with_child if alive? begin yield - rescue Errno::ECONNRESET, Errno::EPIPE + rescue Errno::ECONNRESET, Errno::EPIPE, Errno::EINVAL # The child has died but has not been collected by the wait thread yet, # so start a new child and try again. log "child dead; starting"