Skip to content

Commit 7e21395

Browse files
committed
timeout never returns result
1 parent f93f952 commit 7e21395

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

Sources/Timeout.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public func withThrowingTimeout<T>(
8181
private func _withThrowingTimeout<T>(
8282
isolation: isolated (any Actor)? = #isolation,
8383
body: () async throws -> sending T,
84-
timeout: @Sendable @escaping () async throws -> Void
84+
timeout: @Sendable @escaping () async throws -> Never
8585
) async throws -> Transferring<T> {
8686
try await withoutActuallyEscaping(body) { escapingBody in
8787
let bodyTask = Task {
@@ -155,15 +155,14 @@ public func withThrowingTimeout<T>(
155155
// Sendable
156156
private func _withThrowingTimeout<T: Sendable>(
157157
body: @Sendable @escaping () async throws -> T,
158-
timeout: @Sendable @escaping () async throws -> Void
158+
timeout: @Sendable @escaping () async throws -> Never
159159
) async throws -> T {
160160
try await withThrowingTaskGroup(of: T.self) { group in
161161
group.addTask {
162162
try await body()
163163
}
164164
group.addTask {
165165
try await timeout()
166-
throw TimeoutError("expired")
167166
}
168167
let success = try await group.next()!
169168
group.cancelAll()

0 commit comments

Comments
 (0)