// ThrowingTaskGroup.waitForAll() behaviour was fixed in Swift 5.9 // This backports the Swift 5.9 behaviour to earlier versions // https://github.com/apple/swift/pull/63016 public extension ThrowingTaskGroup { #if compiler(>=5.9) @available(*, deprecated, renamed: "waitForAll") #endif mutating func waitForAllFix() async throws { var firstError: Error? = nil // Make sure we loop until all child tasks have completed while !isEmpty { do { while let _ = try await next() {} } catch { // Upon error throws, capture the first one if firstError == nil { firstError = error } } } if let firstError { throw firstError } } }