{"record":{"id":"904b7afadfd3fdc2","repo":"nanocoai/nanoclaw","slug":"wakecontainer-failed-host-sweep-will-retry","errorCode":null,"errorMessage":"wakeContainer failed — host-sweep will retry","messagePattern":"wakeContainer failed — host-sweep will retry","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/container-runner.ts","lineNumber":147,"sourceCode":" * Contract: never throws. Returns `true` on successful spawn, `false` on\n * transient spawn failure (e.g. OneCLI gateway unreachable). Callers don't\n * need to wrap — the inbound row stays pending and host-sweep retries on its\n * next tick.\n */\nexport function wakeContainer(session: Session): Promise<boolean> {\n  if (activeContainers.has(session.id)) {\n    log.debug('Container already running', { sessionId: session.id });\n    return Promise.resolve(true);\n  }\n  const existing = wakePromises.get(session.id);\n  if (existing) {\n    log.debug('Container wake already in-flight — joining existing promise', { sessionId: session.id });\n    return existing;\n  }\n  const promise = spawnContainer(session)\n    .then(() => true)\n    .catch((err) => {\n      log.warn('wakeContainer failed — host-sweep will retry', { sessionId: session.id, err });\n      return false;\n    })\n    .finally(() => {\n      wakePromises.delete(session.id);\n    });\n  wakePromises.set(session.id, promise);\n  return promise;\n}\n\nasync function spawnContainer(session: Session): Promise<void> {\n  const agentGroup = await getAgentGroup(session.agent_group_id);\n  if (!agentGroup) {\n    log.error('Agent group not found', { agentGroupId: session.agent_group_id });\n    return;\n  }\n\n  // Refresh the destination map and current-thread routing so any admin\n  // changes take effect on wake. Destinations come from the agent-to-agent","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/nanocoai/nanoclaw/blob/294ef2aee85218b23ad30eda9dfe10e590b54a8c/src/container-runner.ts#L129-L165","documentation":"Spawning a session container failed during wakeContainer; the wake is recorded as failed and host-sweep will retry on its next 60s pass. Messages stay queued in inbound.db — nothing is lost, delivery is delayed.","triggerScenarios":"spawnContainer rejects: Docker daemon unreachable, image missing (nanoclaw-agent:latest not built), name/mount/network conflicts, or resource exhaustion on the host.","commonSituations":"Docker not running after host reboot; image removed by `docker system prune`; disk full; a stale container with the same name.","solutions":["Check `docker ps -a | grep <session>` and the error field in the log line","Ensure Docker is running and the image exists: `docker images nanoclaw-agent` — rebuild with `./container/build.sh` if missing","Remove conflicting stale containers for the session","Wait for host-sweep retry or nudge with a new message"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"import { execSync } from 'node:child_process';\nexecSync('docker images nanoclaw-agent:latest'); // fails fast if image missing","typeGuard":null,"tryCatchPattern":"try { await wakeContainer(session); } catch { /* host-sweep retries in 60s; check docker first */ }","preventionTips":["Keep Docker running and the agent image built","Protect data/ and images from aggressive `docker system prune`","Watch logs/nanoclaw.error.log for spawn errors after host reboots"],"tags":["docker","container-spawn","wake","retry"],"backgroundTag":"container-spawn-failed","analyzedSha":"294ef2aee85218b23ad30eda9dfe10e590b54a8c","analyzedAt":"2026-08-28T13:59:10.357Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}