← Commit history

Browser-health watchdog so pup SELF-HEALS from a shared-Chrome crash instead of sitting frozen (John: 'pup seems frozen again' — the Autodesk sign-in flow has crashed the shared adom-you Chrome four times this session). Root cause of the frozen FEELING: when the shared Chrome crashes, the browsers-map entry becomes a dead connection; getOrLaunchBrowser has a real health check but only runs REACTIVELY on the next open, and the dead handle lingers so verbs fail 'Connection closed' and passive verbs return null — pup looks frozen until the user notices. New watchdog probes every browser every 15s with a real CDP call (pages() + 3.5s timeout, catching both crash and hang); a browser that fails TWO consecutive probes (~30s, so a transient slow beat never triggers it) is discarded, its zombie Chromes reaped, its sessions marked _lostBrowser for relaunch, and the recovery is reported through the cleanup queue. So a shared-Chrome crash becomes a ~30s self-heal the user is told about, not an indefinite freeze. Does NOT prevent the crash (root cause still unreproduced deterministically) — makes it a non-event. Two-strike guard prevents killing a briefly-slow-but-alive Chrome.

John Lauer ·525b9bac01 ·3mo ago ·parent 41b26c6
4 files changed +38−6
adom-bridge-puppeteer-manifest.json+4−4
@@ -1,10 +1,10 @@ {   "manifest_version": 1,   "name": "puppeteer",-  "version": "1.9.169",-  "url": "https://wiki.adom.inc/download/adom/adom-desktop-puppeteer-bridge/1.9.169/adom-bridge-puppeteer-v1.9.169.zip",-  "sha256": "1457cac0b41d6082aa82534ff855e7b5663038d11d92170c835efe364297c009",-  "size": 407400,+  "version": "1.9.170",+  "url": "https://wiki.adom.inc/download/adom/adom-desktop-puppeteer-bridge/1.9.170/adom-bridge-puppeteer-v1.9.170.zip",+  "sha256": "8831034c2f26a73b46e8d32568328bbe41b4a5d2911599891c740464c669b398",+  "size": 408105,   "verbPrefixes": [     "browser_",     "desktop_recorder_",
src/BRIDGE_VERSION+1−1
@@ -1 +1 @@-1.9.169+1.9.170
src/bridge.json+1−1
@@ -2,7 +2,7 @@   "manifest_version": 1,   "name": "puppeteer",   "displayName": "Puppeteer (Chrome for Testing + Native)",-  "version": "1.9.169",+  "version": "1.9.170",   "description": "Drives a browser ALREADY on the machine \u2014 installed Chrome, else Microsoft Edge (every Windows PC ships with Edge) \u2014 launched with a FRESH isolated profile, so the common case has NO ~150 MB Chrome-for-Testing download and it never touches the user's real tabs/logins. Binds its local server to LOOPBACK (127.0.0.1) only, so no Windows Firewall 'allow Node through the firewall' prompt ever pops. Chrome for Testing is fetched only as a LAST RESORT if the machine has no Chromium browser at all. SPAWN-VERIFIED fallback: pup tries each detected browser (Chrome \u2192 Edge \u2192 CfT) and actually launches it, falling through to the next if one won't start (and handling browsers like Edge that relaunch onto another PID), so a corrupt/partial install never hard-fails an open. The browser that launches is cached as the default (persisted across restarts) so it isn't re-probed each time. On spawn the bridge SELF-WARMS: detects browsers + disk, and only if the box has no Chrome/Edge and no cached CfT does it background-fetch CfT so the first open is instant. browser_use pins a specific browser (chrome | edge | cft | auto); {browser:'chrome',install:true} downloads & installs REAL Google Chrome (user-scoped, no admin) on an Edge-only box. browser_readiness (READ-ONLY) reports which browser will be used + the full candidate list + the default + free disk. Every failure returns a specific errorCode + _hint (chrome_install_no_disk, chrome_download_network, chrome_install_permission, chrome_stable_not_detected, \u2026). Launches with FULL browser permissions by default for full debug (strictPermissions:true opts out). Headful automation: open/close windows+tabs, navigate, screenshot, eval JS, record. pup is a GENERIC, non-profile browser only \u2014 every session is a fresh isolated Chrome/Edge process, never the user's real signed-in browser; profile defaults to sessionId. To drive the user's REAL Chrome/Edge (their profile, cookies, SSO), use the Adom browser EXTENSION's nbrowser_* verbs \u2014 a separate bridge, not pup's job. macOS (v1.9.74+): full parity with mac-native mechanics \u2014 background-by-default is the app-level hide (windows stay drivable/screenshottable while hidden), raise/lower map to unhide+activate/hide, browser_alert_window posts a native toast whose click focuses the window, browser_use {browser:'chrome',install:true} installs Chrome from the official dmg, and taskbar identity/badging remains Windows-only.",   "homepage": "https://wiki.adom.inc/adom/adom-desktop",   "author": "Adom Inc.",
src/server.js+32
@@ -9974,6 +9974,38 @@ server.listen(PORT, BIND_HOST, async () => {   // net, so an unbranded window can never persist even if its window-opened event was missed.   setTimeout(() => { reclaimUnmanagedWindows().catch(() => {}); }, 12000);   setInterval(() => { reclaimUnmanagedWindows().catch(() => {}); }, 90000);+  // v1.9.170 — BROWSER-HEALTH WATCHDOG. When the shared Chrome crashes or hangs (measured repeatedly+  // on the Autodesk sign-in flow), the browsers-map entry becomes a DEAD handle: the next verb fails+  // 'Connection closed' and pup LOOKS frozen (John: 'pup seems frozen again'). This proactively probes+  // each browser with a real CDP call; a browser that fails TWO consecutive probes (~30s — a real+  // crash/hang, not a transient slow beat) is discarded, its zombie Chromes reaped, its sessions+  // marked _lostBrowser so the next verb relaunches them, and the recovery is REPORTED via the cleanup+  // queue. So pup self-heals instead of stranding the user, and the next open relaunches clean.+  const _healthStrikes = new Map();+  setInterval(async () => {+    if (process.platform !== 'win32') return;+    for (const [profileName, entry] of [...browsers]) {+      let alive = false;+      try {+        await Promise.race([+          entry.browser.pages(),+          new Promise((_, rej) => setTimeout(() => rej(new Error('probe timeout')), 3500)),+        ]);+        alive = true;+      } catch (e) {}+      if (alive) { _healthStrikes.delete(profileName); continue; }+      const strikes = (_healthStrikes.get(profileName) || 0) + 1;+      _healthStrikes.set(profileName, strikes);+      if (strikes < 2) { console.log(`[health] "${profileName}" failed a liveness probe (strike ${strikes}/2) — watching`); continue; }+      _healthStrikes.delete(profileName);+      console.log(`[health] "${profileName}" DEAD/HUNG (2 strikes) — discarding + recovering so pup self-heals`);+      recordCleanup(`pup detected the "${profileName}" Chrome had crashed or hung and cleaned it up — your window(s) will relaunch signed-in on the next open (logins are safe on disk).`);+      try { await entry.browser.close(); } catch (e) {}+      browsers.delete(profileName);+      try { await killOrphanChromesForProfile(profileName); } catch (e) {}+      for (const [, sess] of sessions) { if (sess.profileName === profileName) sess._lostBrowser = true; }+    }+  }, 15000);   // v1.9.166: taskbar-progress reconciler — clear any bar that is lit but shouldn't be.   setInterval(async () => {     if (process.platform !== 'win32' || pupSettings().agentActivity === 'off') return;