openclaw - 💡(How to fix) Fix CLI gateway status may not exit promptly because gateway probe resolves before WebSocket close is drained [3 pull requests]

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…

A short-lived CLI command such as openclaw gateway status may print a complete status report, but the Node.js process can remain alive until killed by an external timeout.

The likely root cause is the gateway probe cleanup path. In the observed built output, probeGateway() calls client.stop() and then resolves immediately. If client.stop() initiates WebSocket close asynchronously, the CLI can finish rendering while a referenced socket handle remains in the event loop.

Error Message

  • openclaw gateway status prints complete output.
  • Process does not always exit promptly after output.
  • Active handle diagnostics showed a remaining socket to the local gateway after status gathering resolved.

Root Cause

gateway status may not exit promptly because gateway probe resolves before WebSocket close is drained

Fix Action

Fixed

Code Example

const settle = (result) => {
  if (settled) return;
  settled = true;
  startAbort.abort();
  clearProbeTimer();
  client.stop();
  resolve(result);
};

---

const settle = (result) => {
  if (settled) return;
  settled = true;
  startAbort.abort();
  clearProbeTimer();
  void (async () => {
    try {
      if (typeof client.stopAndWait === "function") {
        await client.stopAndWait({ timeoutMs: 1000 });
      } else {
        client.stop();
      }
    } catch {
      try { client.stop(); } catch {}
    }
    resolve(result);
  })();
};
RAW_BUFFERClick to expand / collapse

Issue/PR 1: CLI gateway probe can leave a WebSocket handle after output

Title

gateway status may not exit promptly because gateway probe resolves before WebSocket close is drained

Affected version

  • OpenClaw CLI: 2026.5.22
  • Platform: Linux x64

Summary

A short-lived CLI command such as openclaw gateway status may print a complete status report, but the Node.js process can remain alive until killed by an external timeout.

The likely root cause is the gateway probe cleanup path. In the observed built output, probeGateway() calls client.stop() and then resolves immediately. If client.stop() initiates WebSocket close asynchronously, the CLI can finish rendering while a referenced socket handle remains in the event loop.

Observed behavior

  • openclaw gateway status prints complete output.
  • Process does not always exit promptly after output.
  • Active handle diagnostics showed a remaining socket to the local gateway after status gathering resolved.

Environment-specific identifiers, LAN addresses, message IDs, and private paths are intentionally omitted from this report.

Relevant behavior

Conceptually, the current settlement path behaves like this:

const settle = (result) => {
  if (settled) return;
  settled = true;
  startAbort.abort();
  clearProbeTimer();
  client.stop();
  resolve(result);
};

Proposed fix

Await a bounded close-drain before resolving the probe result:

const settle = (result) => {
  if (settled) return;
  settled = true;
  startAbort.abort();
  clearProbeTimer();
  void (async () => {
    try {
      if (typeof client.stopAndWait === "function") {
        await client.stopAndWait({ timeoutMs: 1000 });
      } else {
        client.stop();
      }
    } catch {
      try { client.stop(); } catch {}
    }
    resolve(result);
  })();
};

A shorter timeout such as 250–500 ms may also be acceptable if CLI latency is a concern.

Expected result

  • openclaw gateway status exits promptly after printing.
  • No referenced gateway WebSocket socket remains after the probe promise resolves.

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 CLI gateway status may not exit promptly because gateway probe resolves before WebSocket close is drained [3 pull requests]