From 7e21395de3d8c9c82ad33385a103fa14eb531498 Mon Sep 17 00:00:00 2001 From: Simon Whitty Date: Mon, 9 Sep 2024 07:04:13 +1000 Subject: [PATCH] timeout never returns result --- Sources/Timeout.swift | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Sources/Timeout.swift b/Sources/Timeout.swift index 1b3a4bc..3ea68ae 100644 --- a/Sources/Timeout.swift +++ b/Sources/Timeout.swift @@ -81,7 +81,7 @@ public func withThrowingTimeout( private func _withThrowingTimeout( isolation: isolated (any Actor)? = #isolation, body: () async throws -> sending T, - timeout: @Sendable @escaping () async throws -> Void + timeout: @Sendable @escaping () async throws -> Never ) async throws -> Transferring { try await withoutActuallyEscaping(body) { escapingBody in let bodyTask = Task { @@ -155,7 +155,7 @@ public func withThrowingTimeout( // Sendable private func _withThrowingTimeout( body: @Sendable @escaping () async throws -> T, - timeout: @Sendable @escaping () async throws -> Void + timeout: @Sendable @escaping () async throws -> Never ) async throws -> T { try await withThrowingTaskGroup(of: T.self) { group in group.addTask { @@ -163,7 +163,6 @@ private func _withThrowingTimeout( } group.addTask { try await timeout() - throw TimeoutError("expired") } let success = try await group.next()! group.cancelAll()