Files
openclaw/apps/shared/OpenClawKit/Sources/OpenClawKit
Peter Steinberger 773d60dfb9 fix(macos): bound websocket ping so a dropped pong cannot orphan its continuation (#115362)
* fix(macos): bound websocket ping so a dropped pong cannot orphan its continuation

URLSession drops the pong handler entirely when a web socket task is cancelled or
closed mid-flight. The existing gate guarded a double resume but nothing guarded
zero resumes, so the checked continuation leaked, Swift logged CONTINUATION
MISUSE, and keepaliveLoop's await never returned - wedging the keepalive for the
lifetime of the process.

Race the ping against a deadline and reuse the gate so exactly one resume wins.
Cancellation of the deadline returns without resuming, otherwise a delivered pong
would race the gate and surface as a spurious timeout.

* fix(macos): reuse URLError(.timedOut) instead of a new public ping error

Periphery flags a public enum referenced only inside its own module as dead
code in the shared OpenClawKit intersection scan. URLError keeps the timeout
indistinguishable from a transport timeout for callers, which already handle
URLSession errors from every other path, and adds no public surface.
2026-07-28 14:58:16 -04:00
..