mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 05:30:42 +00:00
fix(browser): ignore handled route navigation races
Co-authored-by: Richard Steadman <198648604+Steady-ai@users.noreply.github.com>
This commit is contained in:
@@ -13,6 +13,7 @@ Docs: https://docs.openclaw.ai
|
||||
|
||||
### Fixes
|
||||
|
||||
- Browser/Playwright: ignore benign already-handled route races during guarded navigation so browser-page tasks no longer fail when Playwright tears down a route mid-flight. (#68708) Thanks @Steady-ai.
|
||||
- Browser/Linux: detect Chromium-based installs under `/opt/google`, `/opt/brave.com`, `/usr/lib/chromium`, and `/usr/lib/chromium-browser` before asking users to set `browser.executablePath`. (#48563) Thanks @lupuletic.
|
||||
- MCP/CLI: retire bundled MCP runtimes at the end of one-shot `openclaw agent` and `openclaw infer model run` gateway/local executions, so repeated scripted runs do not accumulate stdio MCP child processes. Fixes #71457.
|
||||
- OpenAI/Codex image generation: canonicalize legacy `openai-codex.baseUrl` values such as `https://chatgpt.com/backend-api` to the Codex Responses backend before calling `gpt-image-2`, matching the chat transport. Fixes #71460.
|
||||
|
||||
@@ -345,6 +345,34 @@ describe("pw-session createPageViaPlaywright navigation guard", () => {
|
||||
expect(pageClose).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("ignores already-handled route races during guarded navigation", async () => {
|
||||
const { pageGoto, pageClose, getRouteHandler, mainFrame } = installBrowserMocks();
|
||||
const route = createMockRoute({
|
||||
continue: vi.fn(async () => {
|
||||
throw new Error("Route is already handled");
|
||||
}),
|
||||
});
|
||||
pageGoto.mockImplementationOnce(async () => {
|
||||
await dispatchMockNavigation({
|
||||
getRouteHandler,
|
||||
mainFrame,
|
||||
url: "https://example.com",
|
||||
route,
|
||||
});
|
||||
return null;
|
||||
});
|
||||
|
||||
const created = await createPageViaPlaywright({
|
||||
cdpUrl: "http://127.0.0.1:18792",
|
||||
url: "https://example.com",
|
||||
});
|
||||
|
||||
expect(created.targetId).toBe("TARGET_1");
|
||||
expect(route.continue).toHaveBeenCalledTimes(1);
|
||||
expect(pageGoto).toHaveBeenCalledTimes(1);
|
||||
expect(pageClose).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("propagates unsupported redirect protocols as navigation errors", async () => {
|
||||
const { pageGoto, pageClose, getRouteHandler, mainFrame } = installBrowserMocks();
|
||||
mockBlockedRedirectNavigation({
|
||||
|
||||
@@ -818,6 +818,18 @@ export async function assertPageNavigationCompletedSafely(
|
||||
}
|
||||
}
|
||||
|
||||
async function continueRouteSafely(route: Route): Promise<void> {
|
||||
try {
|
||||
await route.continue();
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : "";
|
||||
if (message.includes("Route is already handled")) {
|
||||
return;
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
export async function gotoPageWithNavigationGuard(
|
||||
opts: {
|
||||
cdpUrl: string;
|
||||
@@ -841,7 +853,7 @@ export async function gotoPageWithNavigationGuard(
|
||||
const isSubframeDocument =
|
||||
!isTopLevel && isSubframeDocumentNavigationRequest(opts.page, request);
|
||||
if (!isTopLevel && !isSubframeDocument) {
|
||||
await route.continue();
|
||||
await continueRouteSafely(route);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
@@ -859,7 +871,7 @@ export async function gotoPageWithNavigationGuard(
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
await route.continue();
|
||||
await continueRouteSafely(route);
|
||||
};
|
||||
|
||||
await opts.page.route("**", handler);
|
||||
|
||||
Reference in New Issue
Block a user