← Commit history

Fix the two open defects from John's full sweep. (A) flashCount undercount: the launch flash fires 87 lines BEFORE sessions.set registers the session, so the counter's sessions.get() at flash time always missed — single-tab windows read flash:0 while the orange genuinely fired (the audit column John demanded caught its own instrumentation lying). The credit now happens at registration: if a launch flash was recorded for this sessionId within 60s, count it on the session object that now exists. (B) detached-frame armor: browser_eval caught 'Attempted to use detached Frame' and returned it as an __error RESULT instead of recovering — exactly how two sessions went permanently undrivable in the heavy run. A detached/closed handle is now a recovery signal: re-resolve the session's live page by window.name (the durable carrier from the recovery-binding fix), swap the tab's page reference, and retry the eval once; only if no live page carries pup:<sid> does it surface the error.

John Lauer ·4f6dfdc781 ·3mo ago ·parent 8417a5e
4 files changed +35−8
adom-bridge-puppeteer-manifest.json+4−4
@@ -1,10 +1,10 @@ {   "manifest_version": 1,   "name": "puppeteer",-  "version": "1.9.157",-  "url": "https://wiki.adom.inc/download/adom/adom-desktop-puppeteer-bridge/1.9.157/adom-bridge-puppeteer-v1.9.157.zip",-  "sha256": "56cbced7ebae579a2bcef6f654ceb8d650cbd3c88046b4b4caefb877528a5465",-  "size": 401445,+  "version": "1.9.158",+  "url": "https://wiki.adom.inc/download/adom/adom-desktop-puppeteer-bridge/1.9.158/adom-bridge-puppeteer-v1.9.158.zip",+  "sha256": "bcda0daf7018c39fa640c739168e4fd309d92b61e4384fa72c4cbb12574c9b0b",+  "size": 402033,   "verbPrefixes": [     "browser_",     "desktop_recorder_",
src/BRIDGE_VERSION+1−1
@@ -1 +1 @@-1.9.157+1.9.158
src/bridge.json+1−1
@@ -2,7 +2,7 @@   "manifest_version": 1,   "name": "puppeteer",   "displayName": "Puppeteer (Chrome for Testing + Native)",-  "version": "1.9.157",+  "version": "1.9.158",   "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+29−2
@@ -5510,7 +5510,7 @@ async function launchSession(sessionId, url, { freshProfile = false, profile, st   // real URL's domcontentloaded, which for heavy sites is another 1–3s. Set _flashState so   // the open handler's later scheduleAutoFlash debounces (no double flash). Fire-and-forget.   if (!foreground && !silent && process.platform === 'win32') {-    try { _flashState.set(sessionId, Date.now()); _openFlashDone.set(sessionId, Date.now()); try { const _fs=sessions.get(sessionId); if (_fs) _fs._flashCount=(_fs._flashCount||0)+1; } catch (e) {} console.log(`[flash] "${sessionId}" (launch)`); flashViaAD(sessionId, {}); } catch (e) {}+    try { _flashState.set(sessionId, Date.now()); _openFlashDone.set(sessionId, Date.now()); console.log(`[flash] "${sessionId}" (launch)`); flashViaAD(sessionId, {}); } catch (e) {}   }    if (url) {@@ -5597,6 +5597,10 @@ async function launchSession(sessionId, url, { freshProfile = false, profile, st   if (downloadPath) session._downloadPath = downloadPath;   attachTab(session, sessionId, page);   session._sessionId = sessionId; // v1.8.43: for AD taskbar/flash titleContains resolution+  // v1.9.158 (flash-counter fix): the launch flash fires BEFORE this registration, so counting+  // via sessions.get() at flash time always missed — single-tab windows read flash:0 while the+  // orange really fired (John's audit column caught it). Credit it here, where the session exists.+  if (_flashState.has(sessionId) && Date.now() - _flashState.get(sessionId) < 60000) session._flashCount = (session._flashCount || 0) + 1;   sessions.set(sessionId, session);   activeSessionId = sessionId; @@ -8361,7 +8365,30 @@ const server = http.createServer(async (req, res) => {               20_000, 'page.evaluate'             );           } catch (e) {-            result = { __error: e.message };+            // v1.9.158: a DETACHED page handle is a recovery signal, not a result. Re-resolve the+            // session's live page by window.name (the durable carrier) and retry ONCE — this is the+            // armor for the detached-frame-under-load failure (two sessions went permanently+            // undrivable in the 2026-07-27 heavy run because this error was returned as __error).+            if (/detached Frame|Session closed|Target closed/i.test(e.message || '')) {+              try {+                const be2 = browsers.get(session.profileName);+                let fresh = null;+                if (be2 && be2.browser.isConnected()) {+                  for (const pg of await be2.browser.pages()) {+                    const wn = await pg.evaluate(() => window.name).catch(() => '');+                    if (wn === 'pup:' + resolvedId) { fresh = pg; break; }+                  }+                }+                if (fresh) {+                  tab.page = fresh;+                  try { fresh._pupCreated = true; } catch (e3) {}+                  console.log(`[recover] "${resolvedId}" page handle was detached — re-resolved live page by window.name, retrying eval`);+                  result = await withTimeout(fresh.evaluate(new Function('return (' + args.expr + ')')), 20_000, 'page.evaluate(retry)');+                } else { result = { __error: e.message + ' (re-resolve by window.name found no live page)' }; }+              } catch (e2) { result = { __error: e.message + ' (recovery retry failed: ' + e2.message + ')' }; }+            } else {+              result = { __error: e.message };+            }           }           sendJSON(res, { success: true, output: JSON.stringify({ ok: true, result, sessionId: resolvedId, tabId }) });           return;