openclaw - 💡(How to fix) Fix Proxy signal handlers not removed after normal command completion [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#83881Fetched 2026-05-20 03:47:43
View on GitHub
Comments
1
Participants
2
Timeline
10
Reactions
1
Timeline (top)
mentioned ×3subscribed ×3closed ×1commented ×1

Fix Action

Fix / Workaround

Severity: low / Confidence: medium / Category: maintainability Triage: risk Detected against: openclaw v2026.5.18 (latest stable at time of scan, 2026-05-18) Tooling: clawpatch 0.3.0 + acpx/claude-sonnet-4-5 via Brad Mills protocol


Standardized clawpatch finding. Persistent in v2026.5.18 (not resolved by upgrading from v2026.5.12). Finding ID: fnd_sig-feat-cli-command-0c37e1d71a-_327cf2a1fb.

Code Example

onSigterm = () => shutdown(143);
onSigint = () => shutdown(130);
onExit = () => killStartedProxy();
process.once("SIGTERM", onSigterm);
process.once("SIGINT", onSigint);
process.once("exit", onExit);

---

if (onSigterm) process.off("SIGTERM", onSigterm);
if (onSigint) process.off("SIGINT", onSigint);
RAW_BUFFERClick to expand / collapse

Severity: low / Confidence: medium / Category: maintainability Triage: risk Detected against: openclaw v2026.5.18 (latest stable at time of scan, 2026-05-18) Tooling: clawpatch 0.3.0 + acpx/claude-sonnet-4-5 via Brad Mills protocol

Evidence

  • src/cli/run-main.ts:None-None (runCli)
onSigterm = () => shutdown(143);
onSigint = () => shutdown(130);
onExit = () => killStartedProxy();
process.once("SIGTERM", onSigterm);
process.once("SIGINT", onSigint);
process.once("exit", onExit);

Reasoning

When a proxy is started, onSigterm and onSigint are registered with process.once. The shutdown callback they invoke calls stopStartedProxy() then process.exit(exitCode). After the main command body completes, stopStartedProxy is called to tear down the proxy (setting proxyHandle = null), but the onSigterm / onSigint listeners are never explicitly removed. If SIGTERM or SIGINT arrives during the async teardown phase (memory manager close, harness disposal), the stale handler will call process.exit, skipping the remaining cleanup. The process.once guarantee means each fires at most once, so there is no repeated-execution risk, but the forced exit could race with in-flight teardown I/O.

Reproduction

Start a CLI command that triggers proxy launch, then send SIGTERM during the async teardown window (e.g. closeCliMemoryManagers). Teardown steps after the signal handler's process.exit call are skipped.

Recommendation

Remove the SIGTERM/SIGINT listeners once the command completes and stopStartedProxy has returned:

if (onSigterm) process.off("SIGTERM", onSigterm);
if (onSigint) process.off("SIGINT", onSigint);

Place this before the await-chain for teardown, inside the finally block.

Why existing tests miss this

Signal-during-teardown race conditions are difficult to unit test and no tests are listed for run-main.ts.

Minimum fix scope

Add explicit process.off calls for onSigterm and onSigint in the finally/teardown block of runCli in src/cli/run-main.ts.


Standardized clawpatch finding. Persistent in v2026.5.18 (not resolved by upgrading from v2026.5.12). Finding ID: fnd_sig-feat-cli-command-0c37e1d71a-_327cf2a1fb.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Proxy signal handlers not removed after normal command completion [1 comments, 2 participants]