← Commit history

v1.9.35: defensive AD response parsing, the real cause of the drag-out drain seeing zero events

John Lauer ·2d096b01f4 · ·parent 1298231
5 files changed +39−16
CHANGELOG.md+12
@@ -1,5 +1,17 @@ # Changelog — Adom Desktop Puppeteer Bridge +## 1.9.35 — 2026-07-20 — THE drag-out bug: AD answers in two shapes and pup only understood one++Root cause found. AD's /command replies in TWO shapes depending on path and version: the relay wraps+the payload as {output:"<json string>"}, while the loopback direct API can return the payload BARE.+pup assumed the wrapped shape everywhere, so a bare payload silently collapsed to "" and every field+read as undefined. The drag-out drain therefore saw ZERO events while an identical manual call saw+dozens, and it failed silently because zero events is a legitimate state.++Fixed with one defensive parser (adPayload) that accepts either shape, used by the watch lookup and+the event drain. This class of bug has now bitten twice (desktop_caption, desktop_ui_events), so the+parser is the single place to fix it rather than each call site.+ ## 1.9.34 — 2026-07-20 — Drag-out diagnostics actually deployed, plus a UIA watch leak fix  Two things, one of them a process failure worth naming. The 1.9.33 diagnostic build never reached
adom-bridge-puppeteer-manifest.json+4−4
@@ -1,10 +1,10 @@ {   "manifest_version": 1,   "name": "puppeteer",-  "version": "1.9.34",-  "url": "https://wiki.adom.inc/download/adom/adom-desktop-puppeteer-bridge/1.9.34/adom-bridge-puppeteer-v1.9.34.zip",-  "sha256": "7b2e6573c970acd2a39b562ca93f218301fb2e064b86ce32783002df09ec4a05",-  "size": 285611,+  "version": "1.9.35",+  "url": "https://wiki.adom.inc/download/adom/adom-desktop-puppeteer-bridge/1.9.35/adom-bridge-puppeteer-v1.9.35.zip",+  "sha256": "b6d2dccad42ea2ad1d93bd79a1070e6fbdd2ba7cde02edae0a2fa1f92637ade7",+  "size": 285928,   "verbPrefixes": [     "browser_",     "desktop_recorder_",
src/BRIDGE_VERSION+1−1
@@ -1 +1 @@-1.9.34\ No newline at end of file+1.9.35\ No newline at end of file
src/bridge.json+1−1
@@ -2,7 +2,7 @@   "manifest_version": 1,   "name": "puppeteer",   "displayName": "Puppeteer (Chrome for Testing + Native)",-  "version": "1.9.34",+  "version": "1.9.35",   "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.",   "homepage": "https://wiki.adom.inc/adom/adom-desktop",   "author": "Adom Inc.",
src/server.js+21−10
@@ -2349,6 +2349,22 @@ async function osRaiseSessionWindow(session, sessionId) { // identity, CATEGORY icon and jump list. That keeps "one session = one window" true, keeps titles // unique, and lets a dragged-out digikey tab correctly show the globe instead of inheriting the // wiki book.+// v1.9.35: AD's /command answers in TWO shapes depending on path/version: the relay wraps the+// payload in {output:"<json string>"}, while the loopback direct API can return the payload BARE.+// pup assumed the wrapped shape, so a bare payload silently became "" and every field read as+// undefined — that is why the drag-out drain saw ZERO events while a manual call saw dozens. This+// has now bitten twice (desktop_caption, desktop_ui_events), so parse defensively, once, here.+function adPayload(r) {+  if (!r || typeof r !== 'object') return null;+  let raw = r.output;+  if (raw === undefined || raw === null) {+    // BARE payload: the response IS the payload (no output wrapper).+    return (r.data && typeof r.data === 'object') ? r.data : r;+  }+  if (typeof raw !== 'string') return (raw.data && typeof raw.data === 'object') ? raw.data : raw;+  try { const o = JSON.parse(raw); return (o && o.data && typeof o.data === 'object') ? o.data : o; }+  catch (e) { return null; }+} let _uiWatchId = null; let _uiWatchSeq = 0; let _uiWatchSupported = null;   // null = unprobed, false = AD too old@@ -2359,11 +2375,9 @@ async function ensureWindowOpenedWatch() {     // restart used to subscribe again and never unsubscribe, leaking watches (seen live: w1..w4).     // Events land in ONE shared ring drained by seq, so any existing watch serves us fine.     try {-      const er = await chrome.adCommand('desktop_ui_events', { sinceSeq: 0, max: 1 }, { timeoutMs: 5000 });-      const eraw = er && (typeof er.output === 'string' ? er.output : JSON.stringify(er.output || ''));-      if (eraw) {-        const eo = JSON.parse(eraw);-        const existing = ((eo.data || eo).activeWatches || []).find(w => w.event === 'window-opened' && w.scope === 'global');+      const ep = adPayload(await chrome.adCommand('desktop_ui_events', { sinceSeq: 0, max: 1 }, { timeoutMs: 5000 }));+      if (ep) {+        const existing = ((ep.activeWatches) || []).find(w => w.event === 'window-opened' && w.scope === 'global');         if (existing && existing.watchId) {           _uiWatchId = existing.watchId; _uiWatchSupported = true;           console.log(`[drag] reusing existing window-opened watch (${_uiWatchId}) — no new subscription`);@@ -2441,11 +2455,8 @@ async function drainWindowOpenedEvents() {   await ensureWindowOpenedWatch();   if (!_uiWatchId) { console.log('[drag] drain skipped: no watchId'); return; }   try {-    const r = await chrome.adCommand('desktop_ui_events', { sinceSeq: _uiWatchSeq, max: 200 }, { timeoutMs: 6000 });-    const raw = r && (typeof r.output === 'string' ? r.output : JSON.stringify(r.output || ''));-    if (!raw) { console.log('[drag] drain got NO response from desktop_ui_events'); return; }-    const o = JSON.parse(raw);-    const data = o.data || o;+    const data = adPayload(await chrome.adCommand('desktop_ui_events', { sinceSeq: _uiWatchSeq, max: 200 }, { timeoutMs: 6000 }));+    if (!data) { console.log('[drag] drain: unparseable response'); return; }     const evs = data.events || [];     if (typeof data.nextSeq === 'number') _uiWatchSeq = data.nextSeq;     // v1.9.32: do NOT filter these events by window NAME. A window fires window-opened at CREATION,