Skip to content

Commit

Permalink
timeout never returns result
Browse files Browse the repository at this point in the history
  • Loading branch information
swhitty committed Sep 8, 2024
1 parent f93f952 commit 7e21395
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions Sources/Timeout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public func withThrowingTimeout<T>(
private func _withThrowingTimeout<T>(
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<T> {
try await withoutActuallyEscaping(body) { escapingBody in
let bodyTask = Task {
Expand Down Expand Up @@ -155,15 +155,14 @@ public func withThrowingTimeout<T>(
// Sendable
private func _withThrowingTimeout<T: Sendable>(
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 {
try await body()
}
group.addTask {
try await timeout()
throw TimeoutError("expired")
}
let success = try await group.next()!
group.cancelAll()
Expand Down

0 comments on commit 7e21395

Please sign in to comment.