The fastest browser for AI agents to run browser automation, built for sharing your logged-in browser state with your AI agents, like Codex or Claude Code, without disturbing you. Zero cost, zero config.
JavaScript agent-skillsai-agentautomationbrowserbrowser-automationclaude-codecodexhermes-agentskillsskills-sh
fix(ego-browser): describe an unresponsive Page from every frame discovery
Zhuowei Wang7ee28c70842a
diff --git a/package/ego-browser/src/page-model.test.mjs b/package/ego-browser/src/page-model.test.mjsindex ebaa7fe..0582263 100644--- a/package/ego-browser/src/page-model.test.mjs+++ b/package/ego-browser/src/page-model.test.mjs@@ -7015,3 +7015,37 @@ test("snapshot names the Page and the next step when the Page does not answer",);});});++test("snapshot describes a Page that stops answering after the first document check", async () => {+ await withFixture(async (fixture) => {+ let calls = 0;+ const task = taskForRound(fixture, "round-a", {+ async ensureFrameSessions() {+ calls += 1;+ if (calls === 1) return new Map();+ throw new PageUnresponsiveError("Page.getFrameTree", 800, "target-1");+ },+ async snapshot() {+ return {+ content: 'button "Go" [ref=1]',+ refs: [{ refId: 1, backendNodeId: 1, role: "button", name: "Go" }],+ };+ },+ });+ const page = await openTestPage(task, "https://example.test/late");++ await assert.rejects(+ () => page.snapshot(),+ (error) => {+ assert.equal(error.code, "EGO_PAGE_UNRESPONSIVE");+ assert.match(+ error.message,+ /^Page p1 .*did not answer Page\.getFrameTree within 800ms\./,+ );+ assert.match(error.message, /Page\.stopLoading/);+ return true;+ },+ );+ assert.equal(calls, 2, "the second frame discovery is the one that failed");+ });+});diff --git a/package/ego-browser/src/page-model.ts b/package/ego-browser/src/page-model.tsindex 6cf9626..6186fcf 100644--- a/package/ego-browser/src/page-model.ts+++ b/package/ego-browser/src/page-model.ts@@ -1923,7 +1923,7 @@ class Page {});const iframeSessions =Array.isArray(result?.refs) && result.refs.length > 0- ? await this.#services.ensureFrameSessions(page.targetId)+ ? await this.#frameSessions(page): new Map<string, string>();await preparePageSnapshotResult(this.#services,@@ -2369,8 +2369,7 @@ class Page {refMap,selector,options,- (timeoutMs) =>- this.#services.ensureFrameSessions(page.targetId, timeoutMs),+ (timeoutMs) => this.#frameSessions(page, timeoutMs),);});}@@ -2827,8 +2826,8 @@ class Page {...selectors: string[]): Promise<{ refMap: RefMap; iframeSessions: Map<string, string> }> {const refMap = await this.#refMapForAction(page, sessionId, ...selectors);- const iframeSessions = await this.#services.ensureFrameSessions(- page.targetId,+ const iframeSessions = await this.#frameSessions(+ page,Math.max(1, remainingMs),);return { refMap, iframeSessions };@@ -3299,6 +3298,23 @@ class Page {return popups;}+ /**+ * Frame discovery for this Page. Every call site goes through here so an+ * unresponsive Page is always reported with its label and recovery steps,+ * whichever step of an operation first ran into it.+ */+ async #frameSessions(+ page: PageTarget,+ timeoutMs?: number,+ ): Promise<Map<string, string>> {+ try {+ return await this.#services.ensureFrameSessions(page.targetId, timeoutMs);+ } catch (error) {+ if (!isPageUnresponsiveError(error)) throw error;+ throw await this.#describeUnresponsivePage(error, page);+ }+ }+/*** Replace the runtime's generic "did not answer" error with one that names* this Page and tells the agent what can be done about it. Thrown from here@@ -3376,13 +3392,7 @@ class Page {page: PageTarget,sessionId: string,): Promise<Map<string, string>> {- let iframeSessions: Map<string, string>;- try {- iframeSessions = await this.#services.ensureFrameSessions(page.targetId);- } catch (error) {- if (!isPageUnresponsiveError(error)) throw error;- throw await this.#describeUnresponsivePage(error, page);- }+ const iframeSessions = await this.#frameSessions(page);const readTree = async (session: string) => {const response = await this.#services.cdp("Page.getFrameTree",