Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix(browser): reuse existing Chrome on PM2 restart instead of spawning new windows

Adam Eivyd07b6834a113
diff --git a/browser/server.js b/browser/server.js
index 187851bc6b..e65156246e 100644
--- a/browser/server.js
+++ b/browser/server.js
@@ -38,6 +38,12 @@ async function checkCdp() {
}
async function launchBrowser() {
+ // Reuse existing Chrome if CDP is already reachable (e.g. after PM2 restart)
+ if (await checkCdp()) {
+ console.log(`♻️ Existing Chrome CDP found at ${CDP_HOST}:${CDP_PORT}, reusing`);
+ return;
+ }
+
const config = await loadConfig();
headlessMode = config.headless !== false;
const profileDir = config.userDataDir || DEFAULT_PROFILE_DIR;
@@ -85,7 +91,7 @@ async function launchBrowser() {
// Health check server
const healthServer = createServer(async (req, res) => {
if (req.url === '/health') {
- const connected = chromeProcess && !chromeProcess.killed && await checkCdp();
+ const connected = await checkCdp();
const status = connected ? 'healthy' : 'unhealthy';
res.writeHead(connected ? 200 : 503, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({