Skip to content

fix(daemon): surface probe close reasons#56282

Merged
mbelinky merged 2 commits into
mainfrom
mariano/daemon-probe-close-reasons
Mar 28, 2026
Merged

fix(daemon): surface probe close reasons#56282
mbelinky merged 2 commits into
mainfrom
mariano/daemon-probe-close-reasons

Conversation

@mbelinky

@mbelinky mbelinky commented Mar 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • surface immediate gateway close reasons instead of waiting for a generic probe timeout
  • prefer a concrete close reason over timeout in openclaw daemon status
  • add regression coverage for both probe layers
  • add the required changelog entry under Unreleased > Fixes

Why

This follows the remaining live review comments from #51087. The lightweight probe path could hide actionable auth or pairing failures behind a timeout, which made openclaw daemon status less useful than it should be.

Testing

  • pnpm check on mb-server
  • pnpm test -- src/cli/daemon-cli/probe.test.ts src/gateway/probe.test.ts on mb-server
  • pnpm build on mb-server

Notes

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime cli CLI command changes size: S maintainer Maintainer-authored PR labels Mar 28, 2026
@mbelinky mbelinky marked this pull request as ready for review March 28, 2026 08:52
@greptile-apps

greptile-apps Bot commented Mar 28, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR surfaces immediate WebSocket close reasons (e.g. auth or pairing failures) in openclaw daemon status instead of hiding them behind a generic timeout. It introduces two complementary layers of improvement: src/gateway/probe.ts now early-settles on pre-hello gateway closes (when connectLatencyMs == null), and src/cli/daemon-cli/probe.ts extracts a resolveProbeFailureMessage helper that prefers a concrete close reason over a generic "timeout" when both are present in the result. Both layers are covered by new regression tests.

  • src/gateway/probe.ts: onClose now immediately settles with the formatted close error when it fires before the hello handshake (connectLatencyMs == null), avoiding the full probe timeout.
  • src/cli/daemon-cli/probe.ts: Extracts resolveProbeFailureMessage to prefer close-reason details over "timeout" for post-hello scenarios where the gateway closes during RPC execution.
  • src/gateway/probe.test.ts: Adds startMode/close state to the mock and a new test verifying pre-hello early-settle behavior with no RPC calls made.
  • src/cli/daemon-cli/probe.test.ts: Adds a test verifying the CLI-layer timeout-vs-close preference logic.
  • CHANGELOG.md: Entry correctly placed under Unreleased > Fixes.

Confidence Score: 5/5

Safe to merge — the changes are focused, logically correct, and well-covered by regression tests at both the gateway and CLI layers.

No P0 or P1 issues found. The sentinel check (connectLatencyMs == null) correctly distinguishes pre-hello from post-hello closes. The settle() idempotency guard prevents any double-resolution race. The CLI-layer fallback in resolveProbeFailureMessage correctly handles the remaining post-hello timeout+close scenario. All new code paths have corresponding tests.

No files require special attention.

Important Files Changed

Filename Overview
src/gateway/probe.ts Adds formatProbeCloseError helper and early-settles on pre-hello gateway closes via connectLatencyMs == null guard in onClose — logic is correct and idempotent.
src/cli/daemon-cli/probe.ts Extracts resolveProbeFailureMessage to prefer concrete close reasons over generic timeout strings — correctly handles all error/close combinations.
src/gateway/probe.test.ts Adds startMode/close mock state and a new regression test for pre-hello early-settle; beforeEach resets shared state correctly.
src/cli/daemon-cli/probe.test.ts Adds regression test for timeout-vs-close preference logic in resolveProbeFailureMessage.
CHANGELOG.md Changelog entry correctly added under Unreleased > Fixes.

Reviews (1): Last reviewed commit: "docs(changelog): note daemon probe close..." | Re-trigger Greptile

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c356980aa4

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/gateway/probe.ts
settle({
ok: false,
connectLatencyMs,
error: formatProbeCloseError(close),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve connect-error detail on early close

The new early-settle branch in probeGateway always reports gateway closed (...) and drops any previously captured connectError, which can hide the actual handshake/auth failure. In the real client flow, GatewayClient calls onConnectError with the detailed failure and may then close with a generic reason like connect failed; with this change, daemon status can regress from actionable text (for example, pairing/auth detail) to a generic close reason. Prefer connectError when it exists (or when the close reason is generic/empty) before formatting the close-only message.

Useful? React with 👍 / 👎.

@mbelinky mbelinky merged commit 0afd73c into main Mar 28, 2026
46 of 58 checks passed
@mbelinky mbelinky deleted the mariano/daemon-probe-close-reasons branch March 28, 2026 09:04
@mbelinky

Copy link
Copy Markdown
Contributor Author

Merged via squash.

alexcode-cc pushed a commit to alexcode-cc/clawdbot that referenced this pull request Mar 30, 2026
Merged via squash.

Prepared head SHA: c356980
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Reviewed-by: @mbelinky
alexjiang1 pushed a commit to alexjiang1/openclaw that referenced this pull request Mar 31, 2026
Merged via squash.

Prepared head SHA: c356980
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Reviewed-by: @mbelinky
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
Merged via squash.

Prepared head SHA: c356980
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Reviewed-by: @mbelinky
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
Merged via squash.

Prepared head SHA: c356980
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Reviewed-by: @mbelinky
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
Merged via squash.

Prepared head SHA: c356980
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Reviewed-by: @mbelinky
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
Merged via squash.

Prepared head SHA: c356980
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Reviewed-by: @mbelinky
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes gateway Gateway runtime maintainer Maintainer-authored PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant