Skip to content

fix(signal): drain accepted websocket messages before shutdown - #118975

Merged
steipete merged 3 commits into
mainfrom
codex/qa0803-signal-websocket-shutdown-drain
Aug 3, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/qa0803-signal-websocket-shutdown-drain

Conversation

@steipete

@steipete steipete commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Keep Signal's existing WebSocket-close event-chain draining behavior when shutdown is initiated through an AbortSignal.
  • Allow already received messages to enter durable SQLite ingress before stopping the account.
  • Bound shutdown with a fixed, unrefed 1.5-second grace period; explicitly log potential message loss and terminate if an existing handler cannot complete.

Real behavior proof

  • A real localhost Signal-compatible WebSocket and the production ingress monitor delivered two unique events before abort. Before this fix only one reached SQLite; after the fix both events dispatch and reach completed durable state.
  • 84 complete container owner tests and 124 container/client/ingress sibling tests pass, including buffered close frames, handler failures, pre-aborted connections, synchronous close events, and the exact grace-timeout boundary.
  • Direct installed ws source confirms buffered frames are delivered before the final close event; the official REST adapter consumes received messages without acknowledgment or replay.

Independent review adjudication

  • Two independent manual reviews report zero actionable P0/P1 findings.
  • The single formal review suggested that aborting during the opening handshake would reject the stream. This was independently disproved with the actual installed ws implementation, a real delayed-upgrade localhost server, the production stream, and the full reconnect caller:
{"rawWsEventOrder":["error:WebSocket was closed before the connection was established","close:1006"],"productionResults":[{"mode":"already-aborted","outcome":"resolved","removedAbortListeners":1},{"mode":"immediate-abort","outcome":"resolved","removedAbortListeners":1},{"mode":"during-handshake","outcome":"resolved","removedAbortListeners":1}],"reconnectMessages":[],"recoveringStatuses":0}

The existing production socket error handler only logs; the subsequent close resolves the final event chain. No connection failure or retry occurs.

Inspectable actual WebSocket and SQLite durable-ingress proof

The before/after run uses an actual loopback WebSocket server, production streamContainerEvents, the real Signal ingress monitor, and real per-account SQLite. The first write is briefly blocked to represent ordinary storage contention; sender identities are synthetic.

{"phase":"before","framesDeliveredByServer":2,"callbacks":2,"dispatches":0,"persistedPending":1,"persistedIds":["[\"number:+15550001111\",1700000000001]"],"handlerFailures":1}
{"phase":"after","framesDeliveredByServer":2,"dispatches":[1700000000001,1700000000002],"durable":[{"timestamp":1700000000001,"status":"completed"},{"timestamp":1700000000002,"status":"completed"}],"handlerFailures":0}

Independent real opening-handshake cancellation controls using the actual installed WebSocket implementation confirm no connection-failure or reconnect regression:

{"mode":"already-aborted","outcome":"resolved","errorCount":1,"closed":true}
{"mode":"during-handshake","outcome":"resolved","errorCount":1,"closed":true}
{"runtime":"actual runSignalSseLoop","outcome":"resolved","connections":1,"reconnectMessages":[],"recoveringStatuses":0}

The single socket error is the existing expected cancellation diagnostic; production error handling logs it and the subsequent close resolves normally. Full owner suite: 84 tests; client/adapter/native-ingress siblings: 124 tests.

@openclaw-barnacle openclaw-barnacle Bot added channel: signal Channel integration: signal size: S maintainer Maintainer-authored PR labels Aug 3, 2026
@steipete
steipete merged commit 65fa1f9 into main Aug 3, 2026
95 checks passed
@steipete
steipete deleted the codex/qa0803-signal-websocket-shutdown-drain branch August 3, 2026 21:58
@steipete

steipete commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Aug 3, 2026
* origin/main: (90 commits)
  fix(googlechat): recover durable lanes after oversized attachments (#118986)
  test(qa): cover runtime telemetry evidence (#118950)
  fix(gateway): resolve SQLite usage details (#118918)
  test(cron): cover durable scheduler state (#118981)
  test(gateway): cover node exec approval relay (#118825)
  test(qa): add Active Memory recall coverage (#118963)
  test(qa): promote package-backed Docker artifact proof (#118826)
  test(qa): cover diagnostic event boundary (#118844)
  test(gateway): cover WebSocket runtime contracts (#118797)
  fix(signal): drain accepted websocket messages before shutdown (#118975)
  fix(plugins): remove stale load paths during uninstall (#118930)
  test(qa): cover bundled runtime discovery (#118922)
  chore(clawhub): cover plugin release policy contracts (#118971)
  test(qa): cover support export and stability (#118956)
  fix(feishu): enforce exact signed webhook request boundaries (#118758)
  feat(sms): add Twilio MMS support (#118664)
  test(gateway): prove TLS certificate pinning (#118812)
  test(qa): cover tool policy and sandbox gates (#118925)
  fix(cli): keep update dry-run state immutable (#118856)
  fix(scripts): honor last repeated CLI flag value (#118710)
  ...

# Conflicts:
#	pnpm-workspace.yaml
vincentkoc added a commit that referenced this pull request Aug 3, 2026
…r-admin-20260803

* origin/main: (89 commits)
  fix(googlechat): align doctor policy ownership with canonical account configuration (#118972)
  test(tui): prove editor input through PTY (#118982)
  fix(memory): persist trusted owner provenance at canonical transcript boundary (#118987)
  test(qa): cover health monitor and cache boundaries (#118961)
  fix(macos): restore dashboard frame double-click zoom (#118976)
  fix(googlechat): recover durable lanes after oversized attachments (#118986)
  test(qa): cover runtime telemetry evidence (#118950)
  fix(gateway): resolve SQLite usage details (#118918)
  test(cron): cover durable scheduler state (#118981)
  test(gateway): cover node exec approval relay (#118825)
  test(qa): add Active Memory recall coverage (#118963)
  test(qa): promote package-backed Docker artifact proof (#118826)
  test(qa): cover diagnostic event boundary (#118844)
  test(gateway): cover WebSocket runtime contracts (#118797)
  fix(signal): drain accepted websocket messages before shutdown (#118975)
  fix(plugins): remove stale load paths during uninstall (#118930)
  test(qa): cover bundled runtime discovery (#118922)
  chore(clawhub): cover plugin release policy contracts (#118971)
  test(qa): cover support export and stability (#118956)
  fix(feishu): enforce exact signed webhook request boundaries (#118758)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 4, 2026
…law#118975)

* fix(signal): drain accepted websocket messages before shutdown

* test(signal): avoid returning timer handles from Promise executors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: signal Channel integration: signal maintainer Maintainer-authored PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant