Skip to content

dkg openclaw setup: 30s daemon-start timeout fails when blue-green slot migration is needed #316

@Jurij89

Description

@Jurij89

Summary

pnpm dkg openclaw setup fails on a fresh / nuked ~/.dkg directory because the daemon-start step inside setup is wrapped in a hard 30-second spawnSync timeout, but the first dkg start against an uninitialized ~/.dkg triggers a one-time blue-green slot migration that runs pnpm install in two slots — that takes minutes, not seconds.

The setup command then exits with ETIMEDOUT mid-migration, leaving ~/.dkg in a half-initialized state. dkg init alone does not surface this because it doesn't call dkg start and so doesn't trigger the slot migration.

Reproduction

rm -rf ~/.dkg
pnpm dkg openclaw setup

Output:

DKG OpenClaw Adapter Setup
========================================

[setup] OpenClaw workspace: /home/.../workspace
[setup] Agent name: Sentinel
[setup] Wrote ~/.dkg/config.json (DKG V10 Testnet, edge, port 9200)
[setup] Starting DKG daemon...
Migrating to blue-green release slots...

[setup] ERROR: Failed to start DKG daemon: spawnSync ...node ETIMEDOUT

Root cause

  • packages/adapter-openclaw/src/setup.ts:516-519 calls dkg start via spawnSync(node, [cliPath, 'start'], { stdio: 'inherit', timeout: 30_000 }).
  • packages/cli/src/migration.ts:19-110 (migrateToBlueGreen) runs when ~/.dkg/releases/current doesn't exist. It clones the repo into slots a and b and runs pnpm install --frozen-lockfile in each (the migration's own internal timeout is 10 minutes per INSTALL_TIMEOUT_MS).
  • The setup-side 30s timeout fires long before the migration completes.

Suggested fix

Two reasonable options, either alone is enough:

  1. Skip or extend the daemon-start timeout in setup.ts when first-run migration is detected. Detect by checking for the absence of ~/.dkg/releases/current and either drop the timeout to 0 (no timeout, inherit migration's own bounds) or raise it to a value that covers a realistic pnpm install (~10 minutes).
  2. Run the migration explicitly before the daemon-start step in setup. Call migrateToBlueGreen directly from runSetup so the slot bootstrap completes without going through the timeout-bounded dkg start spawn.

Workaround for users hitting this today

pnpm dkg start          # foreground, completes the slot migration unbounded
pnpm dkg stop           # once the daemon is up, stop it
pnpm dkg openclaw setup --no-start
pnpm dkg start

After the first slot migration completes, all subsequent dkg start calls finish in seconds and dkg openclaw setup works as designed.

Affected

  • packages/adapter-openclaw/src/setup.ts
  • (cross-reference) packages/cli/src/migration.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions