惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
SegmentFault 最新的问题
Jina AI
Jina AI
罗磊的独立博客
V
Visual Studio Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
J
Java Code Geeks
U
Unit 42
Microsoft Azure Blog
Microsoft Azure Blog
B
Blog RSS Feed
爱范儿
爱范儿
酷 壳 – CoolShell
酷 壳 – CoolShell
Last Week in AI
Last Week in AI
T
The Blog of Author Tim Ferriss
腾讯CDC
Hugging Face - Blog
Hugging Face - Blog
T
Tailwind CSS Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
I
InfoQ
月光博客
月光博客
博客园_首页
Vercel News
Vercel News
P
Proofpoint News Feed
GbyAI
GbyAI
Y
Y Combinator Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(ios): guard websocket ping continuation (#88231) · op...
ngutman · 2026-05-30 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -14,6 +14,22 @@ public protocol WebSocketTasking: AnyObject {

1414
1515

extension URLSessionWebSocketTask: WebSocketTasking {}

1616
17+

private final class WebSocketPingContinuationGate: @unchecked Sendable {

18+

private let lock = NSLock()

19+

private var didResume = false

20+
21+

func resumeOnce(_ resume: () -> Void) {

22+

self.lock.lock()

23+

if self.didResume {

24+

self.lock.unlock()

25+

return

26+

}

27+

self.didResume = true

28+

self.lock.unlock()

29+

resume()

30+

}

31+

}

32+
1733

public struct WebSocketTaskBox: @unchecked Sendable {

1834

public let task: any WebSocketTasking

1935

public init(task: any WebSocketTasking) {

@@ -48,8 +64,13 @@ public struct WebSocketTaskBox: @unchecked Sendable {

4864
4965

public func sendPing() async throws {

5066

try await withCheckedThrowingContinuation { (continuation: CheckedContinuation<Void, Error>) in

67+

let gate = WebSocketPingContinuationGate()

5168

self.task.sendPing { error in

52-

ThrowingContinuationSupport.resumeVoid(continuation, error: error)

69+

// URLSession can race ping callbacks with cancellation; only the first

70+

// pong result owns this checked continuation or Swift traps the app.

71+

gate.resumeOnce {

72+

ThrowingContinuationSupport.resumeVoid(continuation, error: error)

73+

}

5374

}

5475

}

5576

}

Original file line numberDiff line numberDiff line change

@@ -11,6 +11,42 @@ private extension NSLock {

1111

}

1212

}

1313
14+

private final class DoubleCallbackPingWebSocketTask: WebSocketTasking, @unchecked Sendable {

15+

private let callbacks: [Error?]

16+
17+

init(callbacks: [Error?]) {

18+

self.callbacks = callbacks

19+

}

20+
21+

var state: URLSessionTask.State { .running }

22+
23+

func resume() {}

24+
25+

func cancel(with closeCode: URLSessionWebSocketTask.CloseCode, reason: Data?) {

26+

_ = (closeCode, reason)

27+

}

28+
29+

func send(_ message: URLSessionWebSocketTask.Message) async throws {

30+

_ = message

31+

}

32+
33+

func sendPing(pongReceiveHandler: @escaping @Sendable (Error?) -> Void) {

34+

for callback in self.callbacks {

35+

pongReceiveHandler(callback)

36+

}

37+

}

38+
39+

func receive() async throws -> URLSessionWebSocketTask.Message {

40+

throw URLError(.badServerResponse)

41+

}

42+
43+

func receive(

44+

completionHandler: @escaping @Sendable (Result<URLSessionWebSocketTask.Message, Error>) -> Void)

45+

{

46+

completionHandler(.failure(URLError(.badServerResponse)))

47+

}

48+

}

49+
1450

private final class FakeGatewayWebSocketTask: WebSocketTasking, @unchecked Sendable {

1551

private let lock = NSLock()

1652

private let helloAuth: [String: Any]?

@@ -193,6 +229,25 @@ private actor SeqGapProbe {

193229
194230

@Suite(.serialized)

195231

struct GatewayNodeSessionTests {

232+

@Test

233+

func websocketPingIgnoresDuplicateSuccessCallbacks() async throws {

234+

let task = DoubleCallbackPingWebSocketTask(callbacks: [nil, nil])

235+

try await WebSocketTaskBox(task: task).sendPing()

236+

}

237+
238+

@Test

239+

func websocketPingIgnoresDuplicateCallbacksAfterFirstError() async throws {

240+

let firstError = URLError(.networkConnectionLost)

241+

let task = DoubleCallbackPingWebSocketTask(callbacks: [firstError, nil])

242+
243+

do {

244+

try await WebSocketTaskBox(task: task).sendPing()

245+

Issue.record("sendPing unexpectedly succeeded")

246+

} catch let error as URLError {

247+

#expect(error.code == firstError.code)

248+

}

249+

}

250+
196251

@Test

197252

func scannedSetupCodePrefersBootstrapAuthOverStoredDeviceToken() async throws {

198253

let tempDir = FileManager.default.temporaryDirectory