Skip to content

fix(tailscale): startup race condition causes transient 'Command failed: tailscale status --json' errors #42798

Description

@archerhpagent

Summary

When the gateway starts with gateway.tailscale.mode: "serve", the startup sequence runs several tailscale commands in rapid succession:

  1. findTailscaleBinary(): which tailscaletailscale --version (binary verification)
  2. enableTailscaleServe(): tailscale serve --bg --yes <port>
  3. getTailnetHostname(): tailscale status --json

Under any system load (e.g., during a gateway restart, or when openclaw status is called), step 3 transiently fails with a non-zero exit code, logged as Command failed: tailscale status --json (visible because verbose/debug logging is enabled).

Environment

  • macOS (arm64), launchd-managed gateway service
  • Tailscale via Homebrew (/opt/homebrew/bin/tailscale, v1.94.1)
  • Daemon socket: /var/run/tailscaled.socket (permissions: srw-rw-rw-)
  • gateway.tailscale.mode: "serve"

Reproduction

Occurs reliably on every gateway restart. The sequence works fine in isolation — the failure is specific to the rapid back-to-back execution during startup under load.

Impact

  • The error is caught (startGatewayTailscaleExposure wraps in try/catch), so the gateway continues to function
  • Tailscale serve still gets configured correctly in most cases
  • The logged error causes user confusion — it looks like a real failure

Suggested Fix

Add a small retry/backoff between enableTailscaleServe and getTailnetHostname, or retry readTailscaleStatusJson on transient failures. A 1-2 retry with a short delay (e.g. 500ms) would eliminate the race without meaningfully slowing startup.

Alternatively, expose a config option for the tailscale binary path (e.g. gateway.tailscale.binaryPath) so users on non-standard setups can skip the discovery chain entirely.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:ux-frictionUser-facing flow adds avoidable confusion or support burden without fully blocking progress.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.maturity:stableIssue affects a taxonomy feature currently scored M4/M5.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions