Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust
Rust ai-agentsai-toolsbrowserbrowser-automationcloud-browserheadlessheadless-browserkitesurfplaywrightpuppeteerrustservoweb-crawlerweb-crawlingweb-scraperweb-scraping
fix(cdp-smoke): wait for worker readiness before evaluating globals
ldm0a68289d630a9
diff --git a/moli-cdp-smoke/README.md b/moli-cdp-smoke/README.mdindex 0fbe0921b..b52c38f97 100644--- a/moli-cdp-smoke/README.md+++ b/moli-cdp-smoke/README.md@@ -255,6 +255,19 @@ both sessions. The identical probe timed out at the replacement evaluation after10,000 ms when Moli's parent-session renderer-inspector detach fix was removed,and passed after the fix was restored.+The Puppeteer DedicatedWorker probe waits for an asserted fixture-message reply+before its first `WebWorker.evaluate()`. `workercreated` and+`Runtime.executionContextCreated` can arrive before worker initialization is+complete. Reading `self.location.pathname` at that point crashed the pinned+Chromium 145.0.7632.6 renderer in 6 of 20 runs with four workers on four CPU+cores, matching the CI `Runtime.callFunctionOn: Target closed` failure. Holding+the worker's `Runtime.runIfWaitingForDebugger` command for 500 ms reproduced+the failure in all three controlled runs; the same runs passed after adding+the fixture round trip. The full Puppeteer group then passed 30 of 30 runs+under the same CPU and worker limits. The original global-value, exact-once+console routing, explicit termination, and navigation teardown checks still+run after readiness is established.+The Puppeteer Shadow DOM accessibility workflow was calibrated on 2026-10-08with puppeteer-core 24.30.0 against `/usr/bin/chromium` 145.0.7632.116, then rununchanged against Moli. `puppeteer_shadow_accessibility.mjs` checks default anddiff --git a/moli-cdp-smoke/moli_cdp_smoke/puppeteer_smoke.mjs b/moli-cdp-smoke/moli_cdp_smoke/puppeteer_smoke.mjsindex a1b0bbffa..1b93eebf2 100644--- a/moli-cdp-smoke/moli_cdp_smoke/puppeteer_smoke.mjs+++ b/moli-cdp-smoke/moli_cdp_smoke/puppeteer_smoke.mjs@@ -323,11 +323,26 @@ async function main() {'Puppeteer workercreated',new Promise(resolve => page.once('workercreated', resolve)),);- await withTimeout('create DedicatedWorker', page.evaluate(() => {- globalThis.__puppeteerDedicatedWorker = new Worker('/worker.js', {+ // workercreated announces the DevTools attachment before the worker script+ // is necessarily running. Wait for a fixture reply before reading worker+ // globals: Chromium can crash on location access during initialization.+ const workerReady = await withTimeout('DedicatedWorker fixture ready', page.evaluate(() => {+ const worker = globalThis.__puppeteerDedicatedWorker = new Worker('/worker.js', {name: 'puppeteer-dedicated-worker',});+ return new Promise((resolve, reject) => {+ worker.addEventListener('message', event => resolve(event.data), { once: true });+ worker.addEventListener('error', event => reject(new Error(event.message)), { once: true });+ worker.postMessage('puppeteer-worker-ready');+ });}));+ if (+ workerReady?.echoed !== 'puppeteer-worker-ready'+ || workerReady.pathname !== '/worker.js'+ || workerReady.selfEqualsGlobal !== true+ ) {+ throw new Error(`unexpected Puppeteer DedicatedWorker readiness reply: ${JSON.stringify(workerReady)}`);+ }const dedicatedWorker = await workerCreated;const dedicatedWorkerProbe = await withTimeout('WebWorker.evaluate',@@ -429,6 +444,7 @@ async function main() {);}record('puppeteer_dedicated_worker_target_runtime_lifecycle', {+ fixtureReady: true,navigationDestroyed: true,workerConsoleMessages,});