{"record":{"id":"ef27083d85b7f84a","repo":"jackwener/OpenCLI","slug":"restarting-daemon-will-disconnect-before-profile","errorCode":null,"errorMessage":"Restarting daemon will disconnect ${before.profiles.length} browser profile(s); the extension should reconnect automatically.","messagePattern":"Restarting daemon will disconnect (.+?) browser profile\\(s\\); the extension should reconnect automatically\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"src/commands/daemon.ts","lineNumber":77,"sourceCode":"  const status = await fetchDaemonStatus();\n  if (!status) {\n    log.info('Daemon is not running.');\n    return;\n  }\n\n  const ok = await requestDaemonShutdown();\n  if (ok) {\n    log.success('Daemon stopped.');\n  } else {\n    log.error('Failed to stop daemon.');\n    process.exitCode = 1;\n  }\n}\n\nexport async function daemonRestart(): Promise<void> {\n  const before = await fetchDaemonStatus();\n  if (before?.profiles && before.profiles.length > 0) {\n    log.warn(`Restarting daemon will disconnect ${before.profiles.length} browser profile(s); the extension should reconnect automatically.`);\n  }\n\n  const result = await restartDaemon();\n  if (!result.stopped) {\n    log.error('Failed to stop daemon before restart.');\n    process.exitCode = 1;\n    return;\n  }\n  if (!result.status) {\n    log.error('Daemon restart timed out before the new daemon reported status.');\n    process.exitCode = 1;\n    return;\n  }\n\n  const action = result.previousStatus ? 'restarted' : 'started';\n  const version = formatDaemonVersion(result.status);\n  log.success(`Daemon ${action} on port ${result.status.port} (${version}).`);\n  if (result.status.extensionConnected) {","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/src/commands/daemon.ts#L59-L95","documentation":"Before restarting the daemon, daemonRestart fetches the current daemon status and warns if connected browser profiles exist, because the restart will sever the WebSocket/native connection between the Browser Bridge extension and the daemon. The message is informational: the extension is expected to reconnect automatically once the new daemon is up. The restart proceeds regardless.","triggerScenarios":"Running the daemon restart command (opencli daemon restart) while one or more browser profiles are attached (before.profiles.length > 0).","commonSituations":"Daemon upgrade or config change performed while a user's Chrome profile has the extension actively connected; CI machines with long-lived browser sessions being restarted; users surprised that automation commands briefly fail during the restart window.","solutions":["Proceed — this is expected behavior; the extension reconnects automatically after restart.","Wait a few seconds after restart and rerun your command if it failed during the reconnection window.","If the extension does not reconnect, reload it in chrome://extensions and verify the daemon is running (daemon status).","Schedule restarts for when no browser automations are in flight to avoid interrupted commands."],"exampleFix":"// before: opencli daemon restart with profiles attached -> warning, brief disconnect\n// after: finish/stop active browser sessions, then restart, then rerun commands","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"await daemonRestart();\nawait new Promise(r => setTimeout(r, 3000)); // allow extension to reconnect\nawait retry(() => browserCommand(), { attempts: 3, delayMs: 2000 });","preventionTips":["Restart the daemon only when no browser automations are in flight.","After restart, wait for the extension to reconnect before issuing browser commands.","Monitor daemon status/profiles to confirm reconnection after restart."],"tags":["daemon","restart","browser-extension","disconnection"],"backgroundTag":"daemon-restart-disconnect","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}