Skip to content

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.

fix(ego-browser): name a probably hung renderer when stopping did not help

Zhuowei Wangac1375d20abc
diff --git a/package/ego-browser/src/driver/page-waits.ts b/package/ego-browser/src/driver/page-waits.ts
index 309543b..6b2709f 100644
--- a/package/ego-browser/src/driver/page-waits.ts
+++ b/package/ego-browser/src/driver/page-waits.ts
@@ -536,7 +536,11 @@ export async function navigateInPage(
// navigation has started but not committed, so leaving it pending would
// hand back a Page that stalls each later call for a full transport
// timeout. The caller asked for a bounded wait: stop the navigation and
- // leave the Page usable on its previous document.
+ // leave the Page usable on its previous document. A hung renderer looks
+ // the same from here and cannot be told apart without an answer from
+ // it; stopping is still safe then, because the navigation this call
+ // itself started is the only load in flight that the caller asked for,
+ // and the frame read after the stop reports what is actually in place.
let stopped = false;
if (probe === "unresponsive") {
const outcome = await stopPendingNavigation(
@@ -680,7 +684,7 @@ function pendingNavigationNote(
if (outcome === "committed") {
return `; ${what} committed at the deadline but its loading was stopped. Call page.reload({ timeout }) if the rest of the document is required.`;
}
- return `; ${what} has not committed and is still pending, so the Page answers no renderer command until it commits. Stop it with page.cdp("Page.stopLoading") or continue on a new Page from task.newPage().`;
+ return `; ${what} has not committed and the Page did not answer even after Page.stopLoading, so its renderer is probably hung. Continue on a new Page from task.newPage(), or close this Page and open it again.`;
}
/** Reload one Page and wait for the selected state of the new document. */
diff --git a/package/ego-browser/src/page-model.test.mjs b/package/ego-browser/src/page-model.test.mjs
index 0ecabbb..b066178 100644
--- a/package/ego-browser/src/page-model.test.mjs
+++ b/package/ego-browser/src/page-model.test.mjs
@@ -2285,9 +2285,9 @@ test("Page.goto names a pending navigation it could not stop", async () => {
assert.equal(error.stopped, false);
assert.match(
error.message,
- /the navigation to "https:\/\/example\.test\/held" has not committed and is still pending/,
+ /the navigation to "https:\/\/example\.test\/held" has not committed and the Page did not answer even after Page\.stopLoading, so its renderer is probably hung/,
);
- assert.match(error.message, /page\.cdp\("Page\.stopLoading"\)/);
+ assert.match(error.message, /task\.newPage\(\)/);
assert.doesNotMatch(error.message, /was stopped/);
return true;
},