From 24bfcfde7a2b835ab37c380bf8b5319987e55454 Mon Sep 17 00:00:00 2001 From: Rintaro Ishizaki Date: Wed, 27 May 2026 10:33:50 -0700 Subject: [PATCH] AsyncQueue: await dependencies concurrently to avoid priority inversion A sequentially-awaited list of dependency tasks only propagates a priority escalation to the dependency currently being awaited. The rest stay at their original priority and can starve under load, producing nondeterministic multi-minute hangs in tests that mix self-serializing and non-self-serializing metadata (e.g. a serial task waiting on many concurrent tasks). Replace the sequential await with concurrentForEach so a priority escalation on the running task reaches every dependency at once. Speculative fix for rdar://178006261 --- Sources/ToolsProtocolsSwiftExtensions/AsyncQueue.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/ToolsProtocolsSwiftExtensions/AsyncQueue.swift b/Sources/ToolsProtocolsSwiftExtensions/AsyncQueue.swift index 5f72f2d1..242d04d6 100644 --- a/Sources/ToolsProtocolsSwiftExtensions/AsyncQueue.swift +++ b/Sources/ToolsProtocolsSwiftExtensions/AsyncQueue.swift @@ -137,7 +137,7 @@ public final class AsyncQueue: Sendable { } } - for dependency in dependencies { + await dependencies.concurrentForEach { dependency in await dependency.task.waitForCompletion() }