all repos — sz-chrome-remote-cdp @ 37756958ead7c98112b7c7bbca5437f45b5839f1

pi-browser-harness, patched to drive a Chrome on another host over CDP, with castle_cdp_search web search

fix(client): guard page-info evaluation against a missing documentElement

The page-info probe read document.documentElement.scrollWidth/scrollHeight
directly, which throws when documentElement is absent. Fall back to zeroed
dimensions so evaluation returns a usable PageInfo instead of failing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
amankumarsingh77 amankumarsingh7702@gmail.com
Sun, 26 Jul 2026 11:35:13 +0530
commit

37756958ead7c98112b7c7bbca5437f45b5839f1

parent

352ac1f95570ae7c64e917ef55e23877a3e5f0ca

1 files changed, 1 insertions(+), 1 deletions(-)

jump to
M src/client.ts → src/client.ts

@@ -256,7 +256,7 @@ const dirty = session.drainPageInfoInvalidations();

const currentTid = session.current()?.targetId; const cached = currentTid ? pageCaches.get(currentTid) : undefined; if (cached && !dirty && Date.now() - cached.at < PAGE_INFO_TTL_MS) return ok(cached.info); - const expr = safeJs`JSON.stringify({url:location.href,title:document.title,w:innerWidth,h:innerHeight,sx:scrollX,sy:scrollY,pw:document.documentElement.scrollWidth,ph:document.documentElement.scrollHeight})`; + const expr = safeJs`JSON.stringify((function(){var e=document.documentElement||{scrollWidth:0,scrollHeight:0};return {url:location.href,title:document.title,w:innerWidth,h:innerHeight,sx:scrollX,sy:scrollY,pw:e.scrollWidth,ph:e.scrollHeight};})())`; const raw = await evaluateJs(expr); if (!raw.success) return raw; if (typeof raw.data !== "string") return err(cdpError("invalid_response", "page info evaluation did not return a string"));