{"record":{"id":"d6cb02b2e24ed4c7","repo":"garrytan/gstack","slug":"browse-client-cannot-find-daemon-port-token-ei","errorCode":null,"errorMessage":"browse-client: cannot find daemon port + token. Either spawn via `$B skill run` (sets GSTACK_PORT + GSTACK_SKILL_TOKEN) or run from a project with a live daemon (.gstack/browse.json must exist).","messagePattern":"browse-client: cannot find daemon port \\+ token\\. Either spawn via `\\$B skill run` \\(sets GSTACK_PORT \\+ GSTACK_SKILL_TOKEN\\) or run from a project with a live daemon \\(\\.gstack/browse\\.json must exist\\)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"browse/src/browse-client.ts","lineNumber":97,"sourceCode":"\n  // 2. State file fallback (developer running `bun run script.ts` directly).\n  const stateFile = opts.stateFile ?? process.env.BROWSE_STATE_FILE ?? defaultStateFile();\n  if (stateFile && fs.existsSync(stateFile)) {\n    try {\n      const data = JSON.parse(fs.readFileSync(stateFile, 'utf-8'));\n      if (typeof data.port === 'number' && typeof data.token === 'string') {\n        return {\n          port: opts.port ?? data.port,\n          token: opts.token ?? data.token,\n          source: 'state-file',\n        };\n      }\n    } catch {\n      // fall through to error\n    }\n  }\n\n  throw new Error(\n    'browse-client: cannot find daemon port + token. Either spawn via `$B skill run` ' +\n    '(sets GSTACK_PORT + GSTACK_SKILL_TOKEN) or run from a project with a live daemon ' +\n    '(.gstack/browse.json must exist).'\n  );\n}\n\nfunction defaultStateFile(): string | null {\n  try {\n    const proc = cp.spawnSync('git', ['rev-parse', '--show-toplevel'], { encoding: 'utf-8', timeout: 2000 });\n    const root = proc.status === 0 ? proc.stdout.trim() : null;\n    const base = root || process.cwd();\n    return path.join(base, '.gstack', 'browse.json');\n  } catch {\n    return path.join(process.cwd(), '.gstack', 'browse.json');\n  }\n}\n\nexport class BrowseClientError extends Error {","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/garrytan/gstack/blob/94993f74012782fd94416dd44b8314f6363a13a4/browse/src/browse-client.ts#L79-L115","documentation":"Error \"browse-client: cannot find daemon port + token. Either spawn via `$B skill run` (sets GSTACK_PORT + GSTACK_SKILL_TOKEN) or run from a project with a live daemon (.gstack/browse.json must exist).\" thrown in garrytan/gstack.","triggerScenarios":"Thrown at browse/src/browse-client.ts:97 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-12T13:17:24.610Z"}