{"record":{"id":"66dd589735882d29","repo":"garrytan/gstack","slug":"timed-out-waiting-for-concurrent-daemon-spawn","errorCode":null,"errorMessage":"Timed out waiting for concurrent daemon spawn","messagePattern":"Timed out waiting for concurrent daemon spawn","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"design/src/daemon-client.ts","lineNumber":143,"sourceCode":"  }\n\n  // Spawn under exclusive lock; re-read state INSIDE the lock so we don't\n  // race a concurrent CLI that won the lock first.\n  const lockPath = resolveLockFilePath(stateFile);\n  const release = acquireLock(lockPath);\n  if (!release) {\n    // Another process is starting the daemon. Wait for it.\n    log(verbose, \"another CLI is spawning the daemon; waiting…\");\n    const start = Date.now();\n    while (Date.now() - start < MAX_START_WAIT_MS) {\n      const fresh = readStateFile(stateFile);\n      if (fresh) {\n        const h = await healthCheck(fresh.port);\n        if (h) return { port: fresh.port, version: h.version, spawned: false };\n      }\n      await delay(POLL_INTERVAL_MS);\n    }\n    throw new Error(\"Timed out waiting for concurrent daemon spawn\");\n  }\n\n  try {\n    // Re-read under lock. Another caller may have already finished spawning\n    // between our first check and our lock acquisition.\n    const fresh = readStateFile(stateFile);\n    if (fresh) {\n      const h = await healthCheck(fresh.port);\n      if (h && h.version === expectedVersion) {\n        log(verbose, `another CLI won the lock; attaching pid=${fresh.pid} port=${fresh.port}`);\n        return { port: fresh.port, version: h.version, spawned: false };\n      }\n    }\n\n    log(verbose, \"spawning new daemon\");\n    const port = await spawnDaemon({\n      script: opts.daemonScript,\n      env: { ...opts.daemonEnv, DESIGN_DAEMON_STATE_FILE: stateFile },","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/garrytan/gstack/blob/94993f74012782fd94416dd44b8314f6363a13a4/design/src/daemon-client.ts#L125-L161","documentation":"Error \"Timed out waiting for concurrent daemon spawn\" thrown in garrytan/gstack.","triggerScenarios":"Thrown at design/src/daemon-client.ts:143 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"94993f74012782fd94416dd44b8314f6363a13a4","analyzedAt":"2026-08-12T04:06:23.140Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}