From e0bffc10cdc59a765a7b3dc8ca739780bde37c30 Mon Sep 17 00:00:00 2001 From: Andy Wang Date: Tue, 1 Dec 2026 15:57:08 +0800 Subject: [PATCH] fix: start the Timeout thread before the tests run Timeout starts one thread for the process on first use and keeps it. Tests that compare thread lists took it for a thread the transport had left behind whenever they were the first to use it. Fixes #739. --- test/test_helper.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/test_helper.rb b/test/test_helper.rb index 8cd6b9e7..224e9db2 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -21,6 +21,13 @@ def Hash.ruby2_keywords_hash?(_hash) require "sorbet-runtime" if RUBY_VERSION >= "3.0" +require "timeout" + +# `Timeout` starts one thread for the whole process on first use and keeps it. Start it before any test runs: +# tests that compare `Thread.list` before and after a step would otherwise take it for a thread the step left behind, +# whenever they happen to be the first to use it. +Timeout.timeout(1) { nil } + require_relative "instrumentation_test_helper" require_relative "initialize_params_test_helper"