From 2d6adba8a8bb0d8ebef83939701e538bbca2502a Mon Sep 17 00:00:00 2001 From: anlicheng <244108715@qq.com> Date: Sun, 3 Aug 2025 01:31:38 +0800 Subject: [PATCH] fix --- Sources/Punchnet/SDLSuperClient.swift | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) 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()