From b91ade15bb4f3ddbac10eaf8c7047e59bdb71a84 Mon Sep 17 00:00:00 2001 From: Andrii Konchyn Date: Fri, 17 Jul 2026 23:51:05 +0300 Subject: [PATCH 1/2] Stop threads synchronously --- lib/listen/adapter/base.rb | 2 +- lib/listen/adapter/darwin.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/listen/adapter/base.rb b/lib/listen/adapter/base.rb index b7e10390..2bf07bc0 100644 --- a/lib/listen/adapter/base.rb +++ b/lib/listen/adapter/base.rb @@ -88,7 +88,7 @@ def stop private def _stop - @run_thread&.kill + @run_thread.kill.join if @run_thread @run_thread = nil end diff --git a/lib/listen/adapter/darwin.rb b/lib/listen/adapter/darwin.rb index 07c7a567..ac7412c4 100644 --- a/lib/listen/adapter/darwin.rb +++ b/lib/listen/adapter/darwin.rb @@ -69,7 +69,7 @@ def _process_event(dir, path) end def _stop - @worker_thread&.kill + @worker_thread.kill.join if @worker_thread super end end From 46700117087781a1426d10304ba3fe7ec78b6571 Mon Sep 17 00:00:00 2001 From: Andrii Konchyn Date: Fri, 17 Jul 2026 23:53:16 +0300 Subject: [PATCH 2/2] Refactor and simplify adapter/polling_spec.rb test because now stopping is synchronous --- spec/lib/listen/adapter/polling_spec.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/lib/listen/adapter/polling_spec.rb b/spec/lib/listen/adapter/polling_spec.rb index fae546fb..6c04380d 100644 --- a/spec/lib/listen/adapter/polling_spec.rb +++ b/spec/lib/listen/adapter/polling_spec.rb @@ -58,9 +58,8 @@ expect(snapshot).to receive(:invalidate). with(:dir, '.', { recursive: true }) - t = Thread.new { subject.start } + subject.start sleep 0.25 - t.kill end end