From a1df2d3e0998e99176a4bfe3cffb83b9e6a2377e Mon Sep 17 00:00:00 2001 From: amankumarsingh77 Date: Sat, 2 May 2026 21:59:30 +0530 Subject: release: v0.3.1 — audit fixes for list_tabs IDs, switch_tab prefix matching, download auto-mkdir, session recovery, docs updates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug fixes: - list_tabs: show full 32-char targetIds (was truncated to 8 chars) - switch_tab: prefix matching fallback for hex prefixes >= 8 chars - download: auto-create directory with mkdir -p - ensureAlive: Runtime.evaluate probe to recover from crashed page targets Docs: - dispatch_key: clarify DOM-only event behavior - navigate: warn about Google anti-bot limitation - network_log: update deprecated promptSnippet - SKILL.md: document actual daemon API (evaluateJs, pageInfo, session.call) - SKILL.md: add troubleshooting for sharp/maxDim and Google navigation - sharp: add to optionalDependencies for screenshot maxDim auto-resize --- src/client.ts | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'src/client.ts') diff --git a/src/client.ts b/src/client.ts index 51dfa9f..1bf7ccc 100644 --- a/src/client.ts +++ b/src/client.ts @@ -108,12 +108,26 @@ export const createBrowserClient = (opts: BrowserClientOptions): BrowserClient = } if (Date.now() - lastHealth < HEALTH_TTL_MS) return ok(undefined); const probe = await transport.request("Target.getTargets", {}, { sessionId: null, timeoutMs: 2_000 }); - if (probe.success) { - lastHealth = Date.now(); - return ok(undefined); + if (!probe.success) { + await stop(); + return start(); } - await stop(); - return start(); + lastHealth = Date.now(); + // Verify the page session is still responsive (handles the case where the + // browser transport is alive but the page target crashed, e.g. localhost died). + const jsProbe = await session.call("Runtime.evaluate", { + expression: "1", returnByValue: true, + }, { timeoutMs: 2_000 }); + if (!jsProbe.success && jsProbe.error.kind === "session_not_found") { + const reattached = await session.attachFirstPage(); + if (reattached.success) { + pageCache = null; + return ok(undefined); + } + await stop(); + return start(); + } + return ok(undefined); }; const evaluateJs = async (expression: string, sessionId?: string): Promise> => { -- cgit v1.2.3