jackwener/OpenCLI · critical · BrowserConnectError
daemon-not-running
daemon-not-running
Error message
Failed to start opencli daemon
What it means
ensureBrowserBridgeReady waited for the daemon to become ready (waitForBridgeReady) but the final health state was not 'ready', so it throws BrowserConnectError with code daemon-not-running. This means the OpenCLI daemon started (or was started) but no Chrome/Chromium extension connected within the timeout.
Source
Thrown at src/browser/daemon-lifecycle.ts:158
}
if (!staleDaemonReplaced && health.state === 'profile-required') {
throw browserConnectErrorFromHealth(health, contextId);
}
if (staleDaemonReplaced || health.state === 'stopped') {
if (verbose && (process.env.OPENCLI_VERBOSE || process.stderr.isTTY)) {
process.stderr.write('⏳ Starting daemon...\n');
}
daemonLifecycleHooks.spawnDaemonProcess();
} else if (verbose && (process.env.OPENCLI_VERBOSE || process.stderr.isTTY)) {
process.stderr.write('⏳ Waiting for Chrome/Chromium extension to connect...\n');
process.stderr.write(' Make sure Chrome or Chromium is open and the OpenCLI extension is enabled.\n');
}
const finalHealth = await waitForBridgeReady(getDaemonHealth, { timeoutMs, contextId, preferredContextId });
if (finalHealth.state === 'ready') return finalHealth;
throw browserConnectErrorFromHealth(finalHealth, contextId);
}
function browserConnectErrorFromHealth(health: DaemonHealth, contextId?: string): BrowserConnectError {
if (health.state === 'profile-required') {
return new BrowserConnectError(
'Multiple Browser Bridge profiles are connected',
'Select one with --profile <name>, OPENCLI_PROFILE=<name>, or opencli profile use <name>.\n' +
'Run opencli profile list to see connected profiles.',
'profile-required',
);
}
if (health.state === 'profile-disconnected') {
const label = contextId ?? health.status.contextId ?? 'unknown';
return new BrowserConnectError(
`Browser profile "${label}" is not connected`,
'Open the matching Chrome profile and make sure the OpenCLI extension is enabled, or choose another profile with opencli profile use <name>.',
'profile-disconnected',
);View on GitHub (pinned to 49907e53dc)
Solutions
- Open Chrome/Chromium and ensure the OpenCLI extension is installed and enabled.
- Restart the browser (or reload the extension) so it reconnects to the daemon, then retry.
- Increase the timeout if the browser/extension takes long to connect on slow machines.
- Check the daemon is actually running (start it manually) and that no firewall blocks its local socket.
Example fix
// before
await runCommand('browser', 'screenshot', { path: 'x.png' }); // throws daemon-not-running
// after: ensure readiness with retry
await ensureBrowserBridgeReady({ verbose: true, timeoutMs: 30000 });
await runCommand('browser', 'screenshot', { path: 'x.png' }); Defensive patterns
Strategy: retry
Validate before calling
const health = await bridge.health();
if (health.state !== 'ready') {
throw new Error('Browser Bridge not ready: open Chrome and enable the OpenCLI extension');
} Type guard
function isBridgeReady(health) {
return health.state === 'ready';
} Try / catch
try {
await runCommand('browser', action, args);
} catch (e) {
if (e.code === 'daemon-not-running') {
await waitForBridgeReady(getDaemonHealth, { timeoutMs: 30000, contextId });
return runCommand('browser', action, args);
}
throw e;
} Prevention
- Ensure Chrome/Chromium runs with the OpenCLI extension enabled before invoking bridge commands.
- Call health() as a pre-flight check in scripts.
- Reload the extension after CLI upgrades so protocol versions match.
- Verify the daemon port/socket is not blocked by firewall or sandboxing.
When it happens
Trigger: Any Browser Bridge command when finalHealth.state !== 'ready' after waitForBridgeReady's timeoutMs — typically Chrome not running, extension disabled, or extension failing to reach the daemon socket.
Common situations: Chrome closed or crashed, OpenCLI extension disabled after a browser update, wrong daemon port/socket, CI environments without a browser, or extension not reloaded after installing the CLI update.
Related errors
- [opencli] daemon ping failed: HTTP ${res.status}
- profile-required
- Detached HEAD — checkout a branch first
- autohome ${contextHint} network error: ${err?.message || err
- coingecko derivatives request failed: ${err?.message ?? err}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/052c59f9447c92f2.
Report an issue: GitHub.