From 8985f865e2f2e918ee1a5c094e94d6e059615f0b Mon Sep 17 00:00:00 2001 From: Lawrence Chen <54008264+lawrencecchen@users.noreply.github.com> Date: Thu, 12 Mar 2026 06:08:27 -0700 Subject: [PATCH] Drain timed out remote daemon semaphores --- Sources/Workspace.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sources/Workspace.swift b/Sources/Workspace.swift index 8ab72d09..496ebeb2 100644 --- a/Sources/Workspace.swift +++ b/Sources/Workspace.swift @@ -718,6 +718,9 @@ final class WorkspaceRemoteDaemonPendingCallRegistry { queue.sync { pendingCalls.removeValue(forKey: call.id) } + // A response can win the race immediately before timeout cleanup removes the call. + // Drain any late signal so DispatchSemaphore is not deallocated with a positive count. + _ = call.semaphore.wait(timeout: .now()) return .timedOut }