BlogDebuggingturno-browser
A blocked redirect that waited 60 seconds
The identity policy took a tab back through history, Chrome restored the page from its back/forward cache, and the wait for DOMContentLoaded never ended. Since turno-browser 0.10.1 the tab loads its last allowed page again and the guard waits only for that page to commit.
- Shipped in
- Author
- William Monroy
turno-browser 0.9.0 added an identity policy that keeps an identity's tabs on a list of allowed domains. A navigation to any other host fails the tool call with an error that names the host and the list. In 0.9.0 and 0.10.0 that error could take a minute to arrive, or not arrive at all.
A browser_navigate whose redirect left the allowed domains could wait the full 60 s navigation timeout. That is also the default limit the MCP TypeScript SDK puts on a request, so the call failed with "Request timed out" instead of the policy's error.
The policy enforces the list in two layers, described at the top of policy-guard.ts.
The first request of a navigation goes through a route on the whole browser context. A request to a host that is not allowed is aborted before it leaves Chrome, Chrome shows its error page, and the tab is taken back.
A redirect cannot be stopped that way. Playwright routes the first request of a navigation but not the hops of a redirect, which the browser follows on its own. So the guard also watches every main-frame commit, and when a tab shows a page of another host, it takes the tab back to its last allowed page.
Both paths end in the same step, and that step was where the time went.
Going back in history
In 0.9.0 the guard took the tab back with page.goBack({ waitUntil: "domcontentloaded" }), and loaded the last allowed page by its URL only if history did not get the tab there.
Going back is something Chrome can do without loading anything. Its back/forward cache keeps a page the tab navigated away from alive, and going back shows that page again. The cache is on by default; turno-browser turns it off only in its low-resource mode.
A page restored from that cache is not loaded again, and Playwright sees no DOMContentLoaded or load for it. The guard was waiting for an event that does not come for a restored page. The tool call whose navigation had been taken back was waiting on the same tab for its own event: a browser_navigate for DOMContentLoaded, a click for load. Each waited until its timeout.
Loading the page again
In 0.10.1 the guard does not use history. It loads the last allowed page by its URL and waits only until that navigation commits, with each step capped at 5 seconds:
const run: Promise<void> = (async () => {
// Done once the tab shows the page: a wait for its load would hold the tab's next revert.
const options = { waitUntil: "commit", timeout: REVERT_WAIT_MS } as const;
const good = this.lastGood.get(page);
if (!good) {
if (await page.opener().catch(() => null)) await page.close();
else if (page.url() !== "about:blank") await page.goto("about:blank", options);
return;
}
await page.goto(good, options).catch(() => null);
const back = !page.isClosed() && navigationVerdict(this.patterns, page.url()).allowed === true;
if (!back && !page.isClosed()) await page.goto("about:blank", options);
})()In Playwright's terms, commit is reached when the response has been received and the document has started loading. The guard does not wait past that, because a wait for the page's load would hold the tab's next take-back. If the tab does not end up on an allowed page, it goes to about:blank. A popup that never showed an allowed page is closed.
The tool result waits for the guard before it reports what was blocked, so that wait has a limit of its own, the same 5 seconds:
/** Resolves once every tab being taken back is done (or after a few seconds). */
async settled(): Promise<void> {
if (!this.pending.size) return;
let timer: NodeJS.Timeout | undefined;
await Promise.race([
Promise.all([...this.pending]),
new Promise<void>((r) => {
timer = setTimeout(r, REVERT_WAIT_MS);
}),
]).finally(() => clearTimeout(timer));
}The test that holds it
The Chrome test of the policy now serves a redirect to a page that never finishes loading. The server writes the start of the document and never ends the response:
if (req.url === "/landed") {
// Never finishes loading: the tab is taken back before this page's DOMContentLoaded, so
// the call that navigated must not wait for one.
res.writeHead(200, { "content-type": "text/html" });
res.write("<!doctype html><title>landed</title>");
return;
}The test navigates to the redirect and then clicks a refused link on the same tab, and both calls must fail with the policy's error. The /landed page never finishes loading, so the browser_navigate returns only because the guard takes the tab to another page instead of waiting on this one. The test also checks that the redirect's hop was the only page request that reached the other host: the direct navigation, the link and the popup were stopped before they left Chrome.
Before and after
Before the fix, in the words of the 0.10.1 changelog, a browser_navigate whose redirect left the allowed domains "could wait the full 60 s navigation timeout", and "a click on a refused link took about 15 s". The changelog does not say how the 15 s was taken. The 60 s is not a measured time: it is the default navigation timeout, the longest such a call could wait, and also the MCP client's limit.
The figures after the fix come from the message of commit 2c8541c, the fix, dated 2026-11-23: "Over 240 CI runs the slowest navigate took 1.8 s and the slowest click 1.2 s." The message says nothing more about how they were taken, so they are the slowest calls across those runs, not a benchmark. No dated run of the same page on both versions has been published, so this post has no chart.
What is still not solved
The tab comes back as a fresh load of its last allowed URL, not as the page the agent left. Before the fix that was also the fallback when history did not help; now it is the only path.
A redirect to another host is still caught only when its page commits. As the policy docs say, that request has reached the other host by then, and only the page is taken back. Scripts, images, requests a page makes and frames inside a page are not checked at all.
The change is pull request 160, released in turno-browser 0.10.1 on 2026-11-23.