Project

General

Profile

Actions

Patch #44265

open

WebhookTest occasionally hangs

Added by Kenta Kumojima about 23 hours ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Code cleanup/refactoring
Target version:
-

Description

Running ./bin/rails test occasionally hangs because WebhookTest never finishes.

This seems to happen in WebhookTest#with_webhook_server when server.shutdown is called before the thread calls server.start. In that case, thread.join then waits forever because the thread never exits.

The issue can be reproduced more reliably by adding a delay before server.start:

diff --git a/test/unit/webhook_test.rb b/test/unit/webhook_test.rb
index 9d0a83f49..4c09c104e 100644
--- a/test/unit/webhook_test.rb
+++ b/test/unit/webhook_test.rb
@@ -366,10 +366,16 @@ class WebhookTest < ActiveSupport::TestCase
       res.body = body
     end
     port = server.listeners.first.addr[1]
-    thread = Thread.new { server.start }
+    thread = Thread.new do
+      sleep 3
+      server.start
+    end
     yield port, received
$ ./bin/rails test test/unit/webhook_test.rb

Run options: --seed 58457

# Running:

(hangs indefinitely)

The attached patch prevents the test from hanging by forcibly terminating the thread if it does not exit within a reasonable amount of time.


Files

kill_webrick_server_thread.patch (687 Bytes) kill_webrick_server_thread.patch Kenta Kumojima, 2026-07-15 10:59

No data to display

Actions

Also available in: Atom PDF