← Commit history

Harden crashed-renderer recovery: respawnCrashedRenderer is now race-safe (one respawn per page; the auto-heal and a manual reload/navigate can no longer collide into a hang) and every CDP call is hard-timeout-bounded, so a crashed target can never wedge the verb. browser_reload now reports tab_renderer_crashed_unrecovered with a close+reopen hint when the in-place respawn cannot recover (e.g. Chrome too memory-pressured), instead of falsely claiming success. Follows the 1.9.176 fix where the recovery could hang under a concurrent auto+manual respawn.

John Lauer ·6bd05bbce2 ·3mo ago ·parent e56f49d
4 files changed +29−14
adom-bridge-puppeteer-manifest.json+4−4
@@ -1,10 +1,10 @@ {   "manifest_version": 1,   "name": "puppeteer",-  "version": "1.9.176",-  "url": "https://wiki.adom.inc/download/adom/adom-desktop-puppeteer-bridge/1.9.176/adom-bridge-puppeteer-v1.9.176.zip",-  "sha256": "ad90aecf54ecc58f40a1ccc8f32089b72d749aa4c7a6f9289f689fb306036491",-  "size": 413111,+  "version": "1.9.177",+  "url": "https://wiki.adom.inc/download/adom/adom-desktop-puppeteer-bridge/1.9.177/adom-bridge-puppeteer-v1.9.177.zip",+  "sha256": "1b429b02deffb531bb9a1615db63ddc857cf994e42f1ea5b2a26b3babbd5fe32",+  "size": 413529,   "verbPrefixes": [     "browser_",     "desktop_recorder_",
src/BRIDGE_VERSION+1−1
@@ -1 +1 @@-1.9.176+1.9.177
src/bridge.json+1−1
@@ -2,7 +2,7 @@   "manifest_version": 1,   "name": "puppeteer",   "displayName": "Puppeteer (Chrome for Testing + Native)",-  "version": "1.9.176",+  "version": "1.9.177",   "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+23−8
@@ -808,21 +808,31 @@ function resolveTabOrError(session, sessionId, args, { allowCrashed = false } = // the RAW target with Page.navigate spawns a fresh renderer in the SAME tab/window/session, which // puppeteer then re-attaches. Returns true once the fresh page answers a probe, false on failure. async function respawnCrashedRenderer(page, url) {+  // Anti-race: the auto-heal (from the crash detector) and a manual browser_reload/navigate can both+  // reach here for the SAME crashed page. Two concurrent createCDPSession + Page.navigate on one+  // crashed target hang. So only ONE respawn runs per page; a second caller waits for it and returns+  // its result. Every CDP call is hard-timeout-bounded so a crashed target can never wedge the verb.+  if (page.__pupRespawning) {+    const dl = Date.now() + 10000;+    while (page.__pupRespawning && Date.now() < dl) await new Promise(r => setTimeout(r, 300));+    try { await withTimeout(page.evaluate('1'), 1500, 'respawn-probe'); return true; } catch (e) { return false; }+  }+  page.__pupRespawning = true;   let cdp = null;   try {-    cdp = await page.target().createCDPSession();-    try { await cdp.send('Page.enable'); } catch (e) {}-    await cdp.send('Page.navigate', { url: url || 'about:blank' });-    const deadline = Date.now() + 8000;+    cdp = await withTimeout(page.target().createCDPSession(), 4000, 'cdp-session');+    try { await withTimeout(cdp.send('Page.navigate', { url: url || 'about:blank' }), 8000, 'page-navigate'); } catch (e) {}+    const deadline = Date.now() + 6000;     while (Date.now() < deadline) {       await new Promise(r => setTimeout(r, 400));-      try { await page.evaluate('1'); return true; } catch (e) { /* frame still respawning */ }+      try { await withTimeout(page.evaluate('1'), 1500, 'respawn-probe'); return true; } catch (e) { /* frame still respawning */ }     }     return false;   } catch (e) {     console.log(`[crash] respawnCrashedRenderer failed: ${e.message}`);     return false;   } finally {+    page.__pupRespawning = false;     try { if (cdp) await cdp.detach(); } catch (e) {}   } }@@ -9276,9 +9286,14 @@ const server = http.createServer(async (req, res) => {           if (tab._crashed) {             const rurl = tab._crashUrl || (() => { try { return tab.page.url(); } catch (e) { return null; } })() || args.url;             const ok = await respawnCrashedRenderer(tab.page, rurl);-            tab._crashed = false; delete tab._crashedAt; delete tab._crashReason;-            console.log(`[crash] session "${resolvedId}" tab ${tabId} recovered via respawn (${ok ? 'ok' : 'sent'})`);-            sendJSON(res, { success: true, output: JSON.stringify({ ok: true, sessionId: resolvedId, tabId, _recovered: `crashed renderer respawned${rurl ? ' at ' + rurl : ''}` }) });+            if (ok) {+              tab._crashed = false; delete tab._crashedAt; delete tab._crashReason;+              console.log(`[crash] session "${resolvedId}" tab ${tabId} recovered via respawn`);+              sendJSON(res, { success: true, output: JSON.stringify({ ok: true, sessionId: resolvedId, tabId, _recovered: `crashed renderer respawned${rurl ? ' at ' + rurl : ''}` }) });+            } else {+              console.log(`[crash] session "${resolvedId}" tab ${tabId} respawn did NOT take — advising close+reopen`);+              sendJSON(res, { success: false, error: `Tab "${tabId}" renderer crashed and in-place respawn did not recover it (Chrome may be too memory-pressured to spawn a fresh renderer). Close and reopen the window: browser_close_window {sessionId:"${resolvedId}"} then browser_open_window {sessionId:"${resolvedId}", url:"${rurl || ''}"}. Closing other heavy pup windows first frees memory.`, errorCode: 'tab_renderer_crashed_unrecovered', sessionId: resolvedId, tabId });+            }             return;           }           // v1.9.109: keep the reload's own HTTP status — page.reload() returns the response, and this