fix(ios): satisfy Sendable in bridge timeout

This commit is contained in:
Peter Steinberger
2025-12-14 03:00:40 +00:00
parent 507f5623f4
commit 7b1163f75c

View File

@@ -87,10 +87,10 @@ actor BridgeSession {
} }
guard let line = try await Self.withTimeout(seconds: 6, operation: { guard let line = try await Self.withTimeout(seconds: 6, operation: {
try await self.receiveLine() try await self.receiveLine()
}), }),
let data = line.data(using: .utf8), let data = line.data(using: .utf8),
let base = try? self.decoder.decode(BridgeBaseFrame.self, from: data) let base = try? self.decoder.decode(BridgeBaseFrame.self, from: data)
else { else {
await self.disconnect() await self.disconnect()
throw NSError(domain: "Bridge", code: 1, userInfo: [ throw NSError(domain: "Bridge", code: 1, userInfo: [
@@ -310,7 +310,7 @@ actor BridgeSession {
} }
} }
private static func withTimeout<T>( private static func withTimeout<T: Sendable>(
seconds: Double, seconds: Double,
operation: @escaping @Sendable () async throws -> T) async throws -> T operation: @escaping @Sendable () async throws -> T) async throws -> T
{ {
@@ -354,7 +354,7 @@ actor BridgeSession {
_ stateStream: AsyncStream<NWConnection.State>, _ stateStream: AsyncStream<NWConnection.State>,
timeoutSeconds: Double) async throws timeoutSeconds: Double) async throws
{ {
try await Self.withTimeout(seconds: timeoutSeconds) { try await self.withTimeout(seconds: timeoutSeconds) {
for await state in stateStream { for await state in stateStream {
switch state { switch state {
case .ready: case .ready: