From ec88c53ba2eaf2aff01eb03ff523cd7152cd2474 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Tue, 28 Jul 2026 12:01:25 +1200 Subject: [PATCH] Add regression test for cancelling pool gardener. --- test/async/pool/controller.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/async/pool/controller.rb b/test/async/pool/controller.rb index c3cb8a9..25708d7 100644 --- a/test/async/pool/controller.rb +++ b/test/async/pool/controller.rb @@ -486,4 +486,19 @@ def failures(repeats: 500, time_scale: 0.001, &block) pool.close end end + + with "cancellation while waiting" do + it "cancels the gardener when closing the pool" do + # Regression test for https://bugs.ruby-lang.org/issues/20907. + # Allocating a resource starts the gardener, which then parks in `#wait`: + resource = pool.acquire + gardener = pool.instance_variable_get(:@gardener) + pool.release(resource) + + # This stops the gardener while it is waiting: + pool.close + + expect(gardener.wait).to be_nil + end + end end