Skip to content

fix(signal): await daemon shutdown on restart - #71863

Closed
ZHOUKAILIAN wants to merge 3 commits into
openclaw:mainfrom
ZHOUKAILIAN:fix/signal-daemon-stop-race
Closed

ZHOUKAILIAN wants to merge 3 commits into
openclaw:mainfrom
ZHOUKAILIAN:fix/signal-daemon-stop-race

Conversation

@ZHOUKAILIAN

@ZHOUKAILIAN ZHOUKAILIAN commented Apr 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • make Signal daemon shutdown asynchronous and await process exit
  • fall back to SIGKILL if signal-cli does not exit after SIGTERM
  • add regression coverage for daemon stop semantics and aborted monitor shutdown

Testing

  • corepack pnpm exec vitest run extensions/signal/src/daemon.test.ts extensions/signal/src/monitor.tool-result.autostart.test.ts
  • corepack pnpm exec vitest run extensions/signal/src

Real behavior proof (required for external PRs)

  • Behavior or issue addressed: Signal auto-start monitor shutdown/restart must wait for the spawned daemon process to exit instead of returning while the daemon is still alive, preventing orphaned signal-cli daemon processes across abort/restart paths.
  • Real environment tested: macOS 14.8.5 arm64 on a local OpenClaw checkout, Node v22.22.2, PR head 3fa74e98e72de378366b4dc5d48cae5f6dd21249. The machine does not have a linked Signal account or signal-cli installed, so this proof used the real OpenClaw Signal monitor/daemon lifecycle code with a local signal-cli-compatible child process that exposes /api/v1/check and /api/v1/events; no external Signal messages were sent.
  • Exact steps or command run after this patch:
cd /Users/zhoukailian/Desktop/mySelf/openclaw/.worktrees/fix-signal-daemon-stop-race
node --import tsx /tmp/openclaw-signal-lifecycle-proof.mjs | tee /tmp/openclaw-signal-lifecycle-proof.out
  • Evidence after fix (screenshot, recording, terminal capture, console output, redacted runtime log, linked artifact, or copied live output):
{
  "repoHead": "3fa74e98e72de378366b4dc5d48cae5f6dd21249",
  "baseMain": "e0225380a7454a85db1038e495d18a28b5d918ed",
  "port": 20031,
  "pid": 34488,
  "aliveBeforeAbort": true,
  "monitorResolved": true,
  "resolveWaitMs": 659,
  "aliveAfterMonitorResolved": false,
  "elapsedMs": 867,
  "events": "START pid=34488 args=[\"daemon\",\"--http\",\"127.0.0.1:20031\",\"--no-receive-stdout\",\"--receive-mode\",\"manual\"]\nSIGTERM pid=34488 at=1778304230573\nEXIT_AFTER_SIGTERM pid=34488 at=1778304231225",
  "runtimeLogs": [
    {
      "level": "log",
      "t": 200,
      "msg": "signal-cli: signal-cli shim READY pid=34488 http=127.0.0.1:20031"
    },
    {
      "level": "error",
      "t": 867,
      "msg": "signal daemon exited (source=process code=0 signal=null)"
    }
  ]
}
  • Observed result after fix: The Signal monitor started the daemon child process, verified it was alive before abort, sent SIGTERM on abort, waited about 659ms for the child to finish its shutdown, then resolved only after the process exited. aliveAfterMonitorResolved: false confirms there was no leftover daemon process after monitorSignalProvider returned.
  • What was not tested: A live linked Signal account, real signal-cli network traffic, actual inbound/outbound Signal message delivery, or the macOS LaunchAgent restart path. This proof is scoped to the changed OpenClaw daemon lifecycle behavior and avoids sending external Signal messages from the test machine.
  • Before evidence (optional but encouraged): The regression tests added in this PR demonstrate the previous behavior: on unpatched main, stop() returned undefined instead of a promise and there was no SIGKILL escalation. The live proof above verifies the patched after-fix runtime behavior on this machine.

Root Cause

  • Root cause: Signal daemon shutdown was fire-and-forget. stop() only sent SIGTERM and returned immediately, so monitor abort/restart could continue while the old daemon process was still shutting down.
  • Missing detection / guardrail: There was no regression coverage asserting that daemon stop returns a promise, waits for process exit, is idempotent across overlapping callers, and escalates to SIGKILL when SIGTERM does not finish.
  • Contributing context (if known): signal-cli daemon shutdown can be slow enough that immediate restart paths race with the previous process still owning resources.

Regression Test Plan

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file:
    • extensions/signal/src/daemon.test.ts
    • extensions/signal/src/monitor.tool-result.autostart.test.ts
  • Scenario the test should lock in: stop() waits for daemon exit after SIGTERM, escalates to SIGKILL after the timeout, reuses an in-flight stop promise, and monitorSignalProvider awaits daemon stop before resolving aborted shutdown.
  • Why this is the smallest reliable guardrail: It exercises the Signal daemon lifecycle seam directly without requiring a live Signal account or sending external messages.
  • Existing test that already covers this (if any): None before this PR.

User-visible / Behavior Changes

Signal auto-start restart/shutdown should leave fewer orphaned daemon processes. Shutdown may now wait briefly for signal-cli daemon to exit; if it does not exit after SIGTERM, OpenClaw escalates to SIGKILL after the configured timeout.

Closes #22676

@openclaw-barnacle openclaw-barnacle Bot added channel: signal Channel integration: signal size: M labels Apr 26, 2026
@greptile-apps

greptile-apps Bot commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR makes the Signal daemon shutdown asynchronous: stop() now returns a Promise<void> that resolves only after the child process exits, with SIGTERM sent immediately and a SIGKILL fallback after 1500 ms. monitorSignalProvider's finally block now awaits the stop so callers are not left with a dangling process on shutdown or restart.

Confidence Score: 4/5

Safe to merge; the async stop logic and SIGKILL fallback are sound, and all new behavior is covered by tests.

Only P2 style observations: a fire-and-forget void call that silently drops errors, and a hardcoded timeout constant in the test. No correctness or logic defects found.

extensions/signal/src/monitor.ts (void stop() on abort) and extensions/signal/src/daemon.test.ts (hardcoded 1500 ms boundary)

Prompt To Fix All With AI
This is a comment left during a code review.
Path: extensions/signal/src/monitor.ts
Line: 437

Comment:
**Unhandled rejection from fire-and-forget stop**

`void daemonLifecycle.stop()` discards any rejection from the async `stop()` call. While `stop()` is unlikely to throw in practice (it only sets a flag and calls `daemonHandle?.stop()`), if it does reject the error is silently lost. The `finally` block already awaits `daemonLifecycle.stop()` for proper cleanup, so the `onAbort` call is primarily used to initiate the signal early — consider wrapping it with a `.catch` to surface unexpected errors.

```suggestion
    void daemonLifecycle.stop().catch((err) => {
      runtime.error?.(`daemon stop error on abort: ${String(err)}`);
    });
```

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: extensions/signal/src/daemon.test.ts
Line: 83

Comment:
**Hardcoded timeout value tightly coupled to implementation**

`vi.advanceTimersByTimeAsync(1_501)` hard-codes knowledge of the 1500 ms kill timeout defined in `daemon.ts`. If the timeout constant is ever changed, this test will break silently (it will advance past the new threshold and the assertions may still pass, but the test no longer verifies the intended boundary). Consider exporting the timeout constant from `daemon.ts` and referencing it here, or adding a comment indicating the coupling.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "fix(signal): await daemon shutdown on re..." | Re-trigger Greptile

Comment thread extensions/signal/src/monitor.ts Outdated
@@ -434,7 +434,7 @@ export async function monitorSignalProvider(opts: MonitorSignalOpts = {}): Promi
}

const onAbort = () => {
daemonLifecycle.stop();
void daemonLifecycle.stop();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Unhandled rejection from fire-and-forget stop

void daemonLifecycle.stop() discards any rejection from the async stop() call. While stop() is unlikely to throw in practice (it only sets a flag and calls daemonHandle?.stop()), if it does reject the error is silently lost. The finally block already awaits daemonLifecycle.stop() for proper cleanup, so the onAbort call is primarily used to initiate the signal early — consider wrapping it with a .catch to surface unexpected errors.

Suggested change
void daemonLifecycle.stop();
void daemonLifecycle.stop().catch((err) => {
runtime.error?.(`daemon stop error on abort: ${String(err)}`);
});
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/signal/src/monitor.ts
Line: 437

Comment:
**Unhandled rejection from fire-and-forget stop**

`void daemonLifecycle.stop()` discards any rejection from the async `stop()` call. While `stop()` is unlikely to throw in practice (it only sets a flag and calls `daemonHandle?.stop()`), if it does reject the error is silently lost. The `finally` block already awaits `daemonLifecycle.stop()` for proper cleanup, so the `onAbort` call is primarily used to initiate the signal early — consider wrapping it with a `.catch` to surface unexpected errors.

```suggestion
    void daemonLifecycle.stop().catch((err) => {
      runtime.error?.(`daemon stop error on abort: ${String(err)}`);
    });
```

How can I resolve this? If you propose a fix, please make it concise.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in c8bf546a. onAbort now keeps the early stop trigger but logs any unexpected rejection via runtime.error before the awaited cleanup path in finally.

it("falls back to SIGKILL if the daemon does not exit in time", async () => {
vi.useFakeTimers();
const fake = createFakeDaemonChild();
spawnMock.mockReturnValue(fake.child);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Hardcoded timeout value tightly coupled to implementation

vi.advanceTimersByTimeAsync(1_501) hard-codes knowledge of the 1500 ms kill timeout defined in daemon.ts. If the timeout constant is ever changed, this test will break silently (it will advance past the new threshold and the assertions may still pass, but the test no longer verifies the intended boundary). Consider exporting the timeout constant from daemon.ts and referencing it here, or adding a comment indicating the coupling.

Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/signal/src/daemon.test.ts
Line: 83

Comment:
**Hardcoded timeout value tightly coupled to implementation**

`vi.advanceTimersByTimeAsync(1_501)` hard-codes knowledge of the 1500 ms kill timeout defined in `daemon.ts`. If the timeout constant is ever changed, this test will break silently (it will advance past the new threshold and the assertions may still pass, but the test no longer verifies the intended boundary). Consider exporting the timeout constant from `daemon.ts` and referencing it here, or adding a comment indicating the coupling.

How can I resolve this? If you propose a fix, please make it concise.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in c8bf546a. Exported SIGNAL_DAEMON_STOP_KILL_TIMEOUT_MS from daemon.ts and updated the test to advance by that shared constant instead of a hardcoded 1501ms.

@clawsweeper

clawsweeper Bot commented Apr 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 3, 2026, 5:57 AM ET / 09:57 UTC.

Summary
The PR changes Signal daemon shutdown to return and await a Promise, escalates from SIGTERM to SIGKILL after a timeout, awaits monitor cleanup, and adds Signal daemon/monitor regression coverage.

PR surface: Source +27, Tests +165. Total +192 across 5 files.

Reproducibility: yes. Current main source shows Signal daemon stop is fire-and-forget SIGTERM, and the PR plus independent discussion provide failing-before/passing-after coverage for awaiting exit and SIGKILL escalation; I did not run a live Signal account restart in this read-only review.

Review metrics: none identified.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #22676
Summary: This PR is the open fix candidate for the canonical Signal daemon restart/shutdown bug.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Maintainers should decide whether the existing gateway channel-stop timeout is enough for the rare post-SIGKILL no-exit case.
  • A linked-account Signal restart proof would further reduce the remaining runtime uncertainty.

Risk before merge

  • [P2] If signal-cli ignores SIGKILL or Node never observes exit/close, the PR's daemon stop promise can remain pending; gateway channel stop has a separate timeout and recovery path, but maintainers still need to accept that availability policy.
  • [P1] The supplied real behavior proof uses a signal-cli-compatible child process rather than a linked Signal account, real Signal traffic, or a live config hot-reload restart.

Maintainer options:

  1. Accept the bounded shutdown policy
    Maintain the PR shape and let the existing gateway channel-stop grace path handle the rare case where a killed child never reports exit.
  2. Bound daemon stop after SIGKILL
    Change the daemon stop promise to resolve or log after the SIGKILL escalation window even if no exit event arrives, then extend the regression test for that path.
  3. Ask for live Signal restart proof
    Request a maintainer-run or contributor-provided linked-account Signal restart proof before accepting the remaining runtime uncertainty.

Next step before merge

  • No automated repair is needed; maintainers need to decide whether the shutdown timeout/escalation behavior and scoped lifecycle proof are sufficient to merge.

Security
Cleared: The patch changes Signal child-process shutdown logic and tests only; it does not add new dependencies, permissions, secrets handling, downloads, or package/CI execution surface.

Review details

Best possible solution:

Land a Signal-owned lifecycle fix once maintainers are comfortable with the 1500 ms SIGKILL escalation policy and the bounded proof scope.

Do we have a high-confidence way to reproduce the issue?

Yes. Current main source shows Signal daemon stop is fire-and-forget SIGTERM, and the PR plus independent discussion provide failing-before/passing-after coverage for awaiting exit and SIGKILL escalation; I did not run a live Signal account restart in this read-only review.

Is this the best way to solve the issue?

Yes. The PR fixes the Signal-owned daemon handle and monitor cleanup instead of adding a gateway delay, while leaving the rare post-SIGKILL no-exit case as an explicit maintainer availability policy decision.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 36dd9ee3c3c1.

Label changes

Label justifications:

  • P1: The PR targets a user-facing Signal restart/shutdown race that can leave daemon processes running and break channel workflow.
  • merge-risk: 🚨 availability: The diff intentionally changes channel shutdown/restart timing and can wait on process-exit behavior during Signal cleanup.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body includes after-fix live output showing the Signal monitor starts a signal-cli-compatible child, aborts it, waits for SIGTERM shutdown, and observes no live child after resolution.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes after-fix live output showing the Signal monitor starts a signal-cli-compatible child, aborts it, waits for SIGTERM shutdown, and observes no live child after resolution.
Evidence reviewed

PR surface:

Source +27, Tests +165. Total +192 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 34 7 +27
Tests 2 167 2 +165
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 201 9 +192

Acceptance criteria:

  • [P1] CI=true node scripts/run-vitest.mjs extensions/signal/src/daemon.test.ts extensions/signal/src/monitor.tool-result.autostart.test.ts.
  • [P1] CI=true node scripts/run-vitest.mjs extensions/signal/src.

What I checked:

  • Current main Signal daemon stop is synchronous: Current main defines SignalDaemonHandle.stop as () => void, and spawnSignalDaemon().stop() only sends SIGTERM when the child is not already killed/exited. (extensions/signal/src/daemon.ts:20, 36dd9ee3c3c1)
  • Current main monitor does not await daemon cleanup: Current main calls daemonLifecycle.stop() from the abort listener and finally block without awaiting child-process exit. (extensions/signal/src/monitor.ts:151, 36dd9ee3c3c1)
  • PR merge ref applies async daemon stop: The merge ref changes SignalDaemonHandle.stop to () => Promise<void>, adds SIGNAL_DAEMON_STOP_KILL_TIMEOUT_MS, sends SIGTERM, escalates to SIGKILL, and resolves after the daemon exit promise. (extensions/signal/src/daemon.ts:20, a55fbb06a3d8)
  • PR merge ref awaits monitor shutdown: The merge ref changes createSignalDaemonLifecycle.stop to await daemonHandle.stop() and awaits daemon lifecycle cleanup in the monitor finally block. (extensions/signal/src/monitor.ts:151, a55fbb06a3d8)
  • Regression tests cover stop semantics: The PR adds daemon tests for waiting after SIGTERM, SIGKILL escalation, and reusing the in-flight stop promise. (extensions/signal/src/daemon.test.ts:100, 8e5e2ab83aea)
  • Gateway has a channel stop grace path: The gateway channel manager aborts channel tasks and waits up to 5000 ms before continuing shutdown/restart recovery, which bounds the broader channel lifecycle if a channel task does not settle. (src/gateway/server-channels.ts:39, 36dd9ee3c3c1)

Likely related people:

  • steipete: Peter Steinberger added Signal provider support and later extracted the daemon lifecycle/typed exit handling that contains the stop behavior this PR changes. (role: introduced behavior and lifecycle refactor author; confidence: high; commits: 596770942adb, 5a0032de3e1c, a94b92694454; files: src/signal/daemon.ts, src/signal/monitor.ts, extensions/signal/src/daemon.ts)
  • scoootscooob: The current extensions/signal/src daemon and monitor files were created by the refactor that moved Signal channel code out of src/signal. (role: major Signal path refactor author; confidence: medium; commits: 4540c6b3bc12; files: extensions/signal/src/daemon.ts, extensions/signal/src/monitor.ts, src/signal/daemon.ts)
  • vincentkoc: Vincent Koc recently touched the Signal monitor test harness around daemon readiness, adjacent to the regression coverage changed by this PR. (role: recent Signal test/runtime contributor; confidence: medium; commits: a0445b192e84, e085fa1a3ffd; files: extensions/signal/src/monitor.tool-result.test-harness.ts, extensions/signal/src/daemon.ts, extensions/signal/src/monitor.ts)
  • shakkernerd: The canonical linked issue is assigned to shakkernerd, who commented that they would reproduce and investigate the orphaned signal-cli process behavior. (role: assigned follow-up owner; confidence: medium; files: extensions/signal/src/daemon.ts, extensions/signal/src/monitor.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@ZHOUKAILIAN

Copy link
Copy Markdown
Contributor Author

Thanks, that makes sense. The PR is intentionally scoped to the Signal daemon/monitor lifecycle, and the current checks are green.

I agree the remaining open point is live Signal restart validation, so I’ll keep this open for maintainer review rather than closing it as obsolete.

@jimdawdy-hub

Copy link
Copy Markdown
Contributor

Independent verification of this PR

🤖 AI-assisted comment. Authored by Jim Dawdy (@jimdawdy-hub) with Claude 4.7 (Anthropic). Verification work was driven by Claude in a sandboxed local environment; human review and the decision to post are mine.

I cherry-picked both commits from this PR (c6c5ad1d63, c8bf546ad6) onto current openclaw/openclaw main and verified them in a sandboxed clone. Branch is preserved at jimdawdy-hub/openclaw@verify-pr-71863 for anyone who wants to inspect the merge state.

Cherry-pick

Cherry-pick onto current main was clean — no conflicts in extensions/signal/src/{daemon.ts,monitor.ts,monitor.tool-result.autostart.test.ts,monitor.tool-result.test-harness.ts}.

Test results

On unpatched main (this PR's new test files dropped in but daemon/monitor source unchanged):

Test Result on unpatched main
waits for exit after SIGTERM before resolving stop ❌ TypeError: Cannot read properties of undefined (reading 'then') — proves stop() returns undefined instead of a promise
falls back to SIGKILL if the daemon does not exit in time ❌ expected 2nd "vi.fn()" call to have been called with [ 'SIGKILL' ], but called only 1 times — proves no escalation exists today
reuses the same in-flight stop promise across repeated stop calls ✅ (passes incidentally on main: both calls return undefined, and child.killed short-circuits the second kill)

The first two failures are exactly the symptoms reported in #22676. They are genuine regressions of the bug, not synthetic.

On the patched branch:

pnpm exec vitest run extensions/signal/src/daemon.test.ts \
                    extensions/signal/src/monitor.tool-result.autostart.test.ts
→ Test Files  2 passed (2)
  Tests       9 passed (9)

Wider Signal extension suite on the patched branch:

pnpm exec vitest run extensions/signal/src
→ Test Files  24 passed (24)
  Tests       215 passed (215)

No regressions in the Signal extension suite.

Code-level review notes

A few things I went looking for and was satisfied by:

  • Reuses existing exitedPromise. stop() awaits the same promise the daemon already resolves on process exit / spawn-error, so there is one source of truth for "the child is gone." Cleaner than racing a parallel exit listener.
  • Idempotent across overlapping callers. The cached stopPromise and the early-return if (exited) return Promise.resolve() mean the monitor's finally path and onAbort handler can both call stop() without double-killing.
  • Bounded escalation. SIGNAL_DAEMON_STOP_KILL_TIMEOUT_MS = 1500 is reasonable for signal-cli's JVM shutdown. Exposed as an export so the test can drive it deterministically with fake timers — nice.
  • Abort handler stays sync-safe. onAbort uses void daemonLifecycle.stop().catch(...) rather than making the listener async, which is correct because addEventListener doesn't await its handler. Errors get logged via runtime.error rather than escaping as unhandled rejections.
  • Test harness type updated. createMockSignalDaemonHandle.stop cast moved from () => void to () => Promise<void> so the rest of the Signal test fleet stays type-honest with the new contract.

What I did NOT verify

Per CONTRIBUTING.md's "Real behavior proof" guidance, I should be explicit:

  • No live signal-cli SIGUSR1 reproduction. I did not stand up a real Signal account, run openclaw gateway start, and trigger config.patch to observe orphaned PIDs disappear. Tests cover the lifecycle logic but not "messages actually send through the new daemon after restart."
  • Linux x86_64, not macOS Apple Silicon (the original report environment). The race is logical, not platform-specific, but I'm not claiming I reproduced the user-visible symptom.
  • Did not run pnpm build && pnpm check && pnpm test repo-wide — only the Signal extension lane.

If a maintainer or @UberKitten can confirm the live macOS path, that would close the remaining gap.

Environment

  • Node v24.14.1, pnpm 10.33.2
  • Cherry-picked onto main at the tip available 2026-05-08
  • Sandboxed clone at /home/jim/oc-sandbox/openclaw, separate from my installed openclaw 2026.5.7

Verdict

The fix is correct, scoped, and has tests that genuinely cover the bug (proven by their failure on unpatched main). Recommending merge from a verification standpoint, with the live-repro caveat above.

Thanks @ZHOUKAILIAN for the clean implementation.

@ZHOUKAILIAN
ZHOUKAILIAN force-pushed the fix/signal-daemon-stop-race branch from c8bf546 to e333a6f Compare May 9, 2026 04:35
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label May 9, 2026
@ZHOUKAILIAN
ZHOUKAILIAN force-pushed the fix/signal-daemon-stop-race branch 3 times, most recently from 232bc33 to 3fa74e9 Compare May 9, 2026 04:46
@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 9, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 9, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P1 High-priority user-facing bug, regression, or broken workflow. labels May 20, 2026
@clawsweeper

clawsweeper Bot commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

✨ Hatched: ✨ glimmer Velvet Proofling

Hatch command

Comment @clawsweeper hatch when this PR is hatchable.

Hatchability rules:

  • Merged PRs are hatchable.
  • Open PRs are hatchable when they are status: 👀 ready for maintainer look, status: 🚀 automerge armed, or labeled clawsweeper:automerge.
  • Closed unmerged PRs are hatchable only when one of those hatchable labels is still present in the durable record.

Rarity: ✨ glimmer.
Trait: polishes edge cases.
Image traits: location proof lagoon; accessory rollback rope; palette moss green and polished brass; mood curious; pose pointing at a small proof artifact; shell matte ceramic shell; lighting subtle sparkle highlights; background quiet workflow signs.
Share on X: post this hatch
Copy: My PR egg hatched a ✨ glimmer Velvet Proofling in ClawSweeper.

What is this egg doing here?
  • Eggs appear after the PR passes real-behavior proof. It is here for vibes, not verdicts: it does not change labels, ratings, merge decisions, or automation.
  • The shell reacts to review momentum: open follow-up work warms it up, re-review makes it wobble, and a clean final review lets it hatch.
  • Hatchability usually comes from sufficient real-behavior proof, no blocking P0/P1/P2 findings, no security attention needed, and clean correctness. A merged PR is already final, so merge makes the egg hatchable independently.
  • The hatch is seeded from this repository and PR number, so the same PR keeps the same creature; the reviewed head SHA can only change safe visual details.
  • Rarity is just collectible sparkle: 🥚 common, 🌱 uncommon, 💎 rare, ✨ glimmer, and 🌈 legendary.

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. label May 20, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jun 14, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jun 14, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Jun 15, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jun 15, 2026
# Conflicts:
#	extensions/signal/src/daemon.test.ts
@ZHOUKAILIAN
ZHOUKAILIAN force-pushed the fix/signal-daemon-stop-race branch from 3fa74e9 to cb68041 Compare June 15, 2026 06:35
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jun 15, 2026
@ZHOUKAILIAN

Copy link
Copy Markdown
Contributor Author

Refreshed this PR onto current main on June 15, 2026 and force-pushed the updated branch (cb68041451).

Local verification on the refreshed branch:

  • CI=true node scripts/run-vitest.mjs extensions/signal/src/daemon.test.ts extensions/signal/src/monitor.tool-result.autostart.test.ts
  • CI=true node scripts/run-vitest.mjs extensions/signal/src

Both passed locally after syncing the worktree dependencies to current main. GitHub checks are rerunning on the refreshed head now.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jun 15, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jun 15, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jun 15, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Jul 3, 2026
@steipete

Copy link
Copy Markdown
Contributor

Superseded by #107409, landed as 5688d90.

The replacement preserves current main's readline-safe signal-cli output handling while carrying the core fix forward: async/idempotent daemon stop, SIGTERM then SIGKILL escalation, and restart only after actual process exit. Deep review also fixed post-spawn child-process error handling and added focused shutdown/restart tests. Contributor credit is preserved via Co-authored-by.

Thank you @ZHOUKAILIAN for identifying the race and contributing the original fix.

@steipete steipete closed this Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: signal Channel integration: signal merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Signal daemon stop() race condition on SIGUSR1 restart — orphaned processes and send failures

3 participants