diff --git a/Sources/Basics/Concurrency/ConcurrencyHelpers.swift b/Sources/Basics/Concurrency/ConcurrencyHelpers.swift index 2837bea4b95..ad6513f0add 100644 --- a/Sources/Basics/Concurrency/ConcurrencyHelpers.swift +++ b/Sources/Basics/Concurrency/ConcurrencyHelpers.swift @@ -27,6 +27,12 @@ public enum Concurrency { @available(*, noasync, message: "This method blocks the current thread indefinitely. Calling it from the concurrency pool can cause deadlocks") public func unsafe_await(_ body: @Sendable @escaping () async -> T) -> T { + withUnsafeCurrentTask { task in + if task != nil { + fatalError("This function must not be invoked from the Swift Concurrency thread pool.") + } + } + let semaphore = DispatchSemaphore(value: 0) let box = ThreadSafeBox()