Skip to content

Commit bda3755

Browse files
justin808claude
andcommitted
Add timeout and KILL fallback to server shutdown
- Add 10-second timeout to Process.wait to prevent indefinite hangs - Send KILL signal if server doesn't respond to TERM within timeout - Prevents test runs from hanging if server doesn't shut down gracefully - Logs warning when escalating from TERM to KILL This ensures robust cleanup even when servers are unresponsive to graceful shutdown signals. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 8e2b944 commit bda3755

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/cypress_on_rails/server.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,16 @@ def stop_server(pid)
155155

156156
puts "Stopping Rails server (PID: #{pid})"
157157
send_term_signal(pid)
158-
Process.wait(pid)
158+
159+
begin
160+
Timeout.timeout(10) do
161+
Process.wait(pid)
162+
end
163+
rescue Timeout::Error
164+
CypressOnRails.configuration.logger.warn("Server did not terminate after TERM signal, sending KILL")
165+
safe_kill_process('KILL', pid)
166+
Process.wait(pid) rescue Errno::ESRCH
167+
end
159168
rescue Errno::ESRCH
160169
# Process already terminated
161170
end

0 commit comments

Comments
 (0)