diff --git a/Sources/Punchnet/SDLSuperClient.swift b/Sources/Punchnet/SDLSuperClient.swift index 6986c8f..4700fd0 100644 --- a/Sources/Punchnet/SDLSuperClient.swift +++ b/Sources/Punchnet/SDLSuperClient.swift @@ -100,13 +100,19 @@ actor SDLSuperClient { // --MARK: 心跳机制 group.addTask { while true { - try Task.checkCancellation() - //await self.ping() - try Task.checkCancellation() - try await Task.sleep(nanoseconds: 5 * 1_000_000_000) - try Task.checkCancellation() + + do { + + try Task.checkCancellation() + //await self.ping() + try Task.checkCancellation() + try await Task.sleep(nanoseconds: 5 * 1_000_000_000) + try Task.checkCancellation() + } catch let err { + NSLog("[SDLSuperClient] heartbeat cancelled") + throw err + } } - NSLog("[SDLSuperClient] heartbeat cancelled") } try await group.waitForAll()