From 884859369f81c91cc45627f3889062092b6e4055 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 1de64a19..0a193b13 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.3.0 * Fix reloading issue in Ruby 3.3. diff --git a/lib/spring/application_manager.rb b/lib/spring/application_manager.rb index 6ac016d8..ce8c63bc 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"