Repository navigation
Description
Version
@playwright/cli 0.1.22 with playwright-core 1.64.1 (also seen with 0.1.21 / playwright-core 1.64.0-alpha). Chromium 154 on Linux. Code unchanged on microsoft/playwright main at b4695e3eb2.
Steps to reproduce
- Start Chromium with
--remote-debugging-port=9222and use it normally, with many tabs (here 28). In our case a hidden tab that had been reloaded ended up in this state; we have no deterministic way to create it from scratch. - Run
playwright-cli -s=s attach --cdp=http://127.0.0.1:9222.
Expected
Attach completes, listing the tabs. A tab that cannot report its title is listed without one.
Actual
attach never returns. The session daemon stays registered, and every later command (even run-code 'async page => 1') queues behind it and hangs too, until the session is detached.
Analysis
- CDP is fine:
chromium.connectOverCDPconnects in 0.6–0.8 s, and withDEBUG=pw:protocolall 641 CDP requests of the attach got answers. - With
DEBUG=pw:channel, the one call that never returns isframe.title(). Tab.headerSnapshot()(packages/playwright-core/src/tools/backend/tab.ts) runs on attach and after every command, for every tab, and awaitsthis.page.title()with no timeout:if (!this.crashed) { await this._raceAgainstModalStates(async () => { title = await this.page.title(); });
- For the blocking tab, Playwright's main frame is half-initialised:
page.url()is""and the frame's load states are only["commit"]. Sotitle()waits forever for a main-world execution context. The same tab is fine over raw CDP:Runtime.evaluateanswers in about 1 ms,Page.getFrameTreeworks, readyState is complete, and the tab is not discarded or prerendering. - The
!this.crashedguard ([Bug] playwright-cli: one discarded (Memory Saver) tab makes every command time out — tab header rendering awaits page.title() without timeout playwright#41714) and fix(chromium): do not hang on pages without a renderer when connecting over CDP playwright#42936 (in 1.64.1) cover discarded and crashed tabs only; 1.64.1 still hangs here.
Minimal probe (touches no tab):
const { chromium } = require('playwright-core');
(async () => {
const browser = await chromium.connectOverCDP('http://127.0.0.1:9222');
for (const page of browser.contexts()[0].pages()) {
const outcome = await Promise.race([page.title().then(() => 'ok'), new Promise(r => setTimeout(r, 3000, 'HANGS'))]);
if (outcome !== 'ok') console.log(outcome, JSON.stringify(page.url())); // -> HANGS ""
}
process.exit(0);
})();Workaround we use
We bound the call: 3 s for the first wait, then 100 ms per later snapshot while the same pending title() is still unresolved, and leave the title empty. With it, attach takes 3.7 s instead of hanging, later commands take 0.3 s, and the tab is listed as - 6: [](). Unpatched, the same browser times out at 60 s every time.
Suggestion
Bound title() in headerSnapshot() (a small change; PR to follow in microsoft/playwright). Separately, the frame never leaving the "commit"/url "" state while the renderer is loaded may be a bug in frame tracking after connectOverCDP; we can collect a pw:protocol log for that tab if it helps.
Activity
dgozman commentedon Oct 26, 2026
cyppe Any chance you can dump the contents of
chrome://discardsandchrome://process-internals(all three tabs there) next time this happens? We really need to figure out what's the state of the page that preventsattachfrom completing, to figure out a long-term solution.github-actions commentedon Oct 31, 2026
github-actions commentedon Oct 31, 2026
Hi, I'm the Playwright bot. I tried to reproduce this on Linux.
I could not recreate the half-initialized frame, on current main or with
playwright-core1.64.1. With 28 tabs, background reloads and frozen tabs, attachment and later commands completed. A coverage test for attachment after a background-tab reload is proposed; it does not fix or simulate the reported missing execution context.One relevant detail:
page.title()evaluates in Playwright's utility world, not the default world used by bare CDPRuntime.evaluate. A successful default-world evaluation does not establish that the utility-world context was initialized. The timeout patch in microsoft/playwright#43620 was closed without merging, so I have not repeated it.Could you share a sanitized
DEBUG=pw:protocol,pw:channellog starting before the failingattach, together with thechrome://discardsandchrome://process-internalsdumps requested above? The missing piece is a way to create, or inspect initialization of, the affected frame.What I ran
All runs were on Linux. Each probe used 28 tabs and checked all titles after CDP connection, with a five-second bound on title collection. Variations were ordinary loaded tabs, a frozen background tab, reload while frozen, thawing that tab, and 20 reload/connection races.
1.65.0-next,a6fb02f5aa494764a21a637f2db6ea1031461935158.0.8127.2156.0.8078.470.1.22, pinned core1.64.0-alpha-1790635538000, upstreame8149b8257d32dcf8f72573ecc43e72439da7080155.0.8059.120.1.22, core1.64.1, upstreamcfe490d941f992655948eee8fd4fd94e1c4234bf156.0.8078.47For upstream Chrome, the pinned core, and core 1.64.1, I also disabled the original session's focus emulation and confirmed
document.hidden === trueon the background tab before testing. In the four non-race states, actual CLIattach,tab-list, andrun-code 'async page => 1'all completed and returned the expected titles/result. No probe produced the reported empty-URL frame.The reporter's Chromium 154 and long-running browser profile were not available. These results do not establish that the bug is fixed.
The existing
attach via cdptest now includes the background reload and checks attachment metadata, a snapshot, and a laterrun-coderesult.cli-cdp.spec.tsandcli-endpoint.spec.tspassed across the Chrome, Chromium, Firefox, and WebKit projects: 42 passed, 14 skipped. CDP-only cases are skipped for Firefox and WebKit. Build and the fullnpm run flintcheck passed.Condensed scenario covered by the proposal
Using the repository's
cdpServer,cli, andserverfixtures:This passes today. It covers the background-reload setup, not the unknown trigger that leaves a frame without an execution context.
Draft PR: microsoft/playwright#43816
Triaged on Linux by the Playwright bot - agent run
pavelfeldman commentedon Oct 31, 2026
Closing as not reproducible
roman-vm commentedon Nov 15, 2026
Reproduced, deterministically, with a fresh profile and local pages only.
Chrome 157.0.8103.52 on Windows 11 (
--headless=new). It fails the same way on playwright-core 1.64.1, 1.65.1 and 1.66.0-alpha-2026-11-15, and with playwright-cli 0.1.22 and 0.1.24.Trigger. A CDP client sees a tab, and later that tab switches to a prerendered page. One
Target.getTargetsthat then disconnects is enough. From then on, the tab's page target id and its main frame id differ:Control: the same steps with no early CDP client. The ids match and
title()resolves:With the real CLI against that Chrome,
attachprints the new session and thenTimeout 30000ms exceeded.. After that,tab-listnever returns.The repro triggers the prerender with speculation rules. My guess at the everyday path, which I have not verified: a browser with remote debugging on, where earlier attaches (an MCP server, earlier
playwright-cli attachruns) have listed every tab, and the user later opens a page Chrome prerendered.Cause (crPage).
_sessionForFrame()walks up from a frame until it finds a session keyed by that frame's id. That assumes the main frame's id equals the target id. Here it doesn't, so the walk runs out of parents and throwsFrame has been detached.. Both_onFrameNavigatedand_onExecutionContextCreatedcall it, through_eventBelongsToStaleFrame(). The result:page.url()stays"";title()waits for the utility world forever;Tab.headerSnapshot()awaits thattitle()with no timeout, so every CLI command hangs.As a probe, not a proposed fix: when
_sessionForFrameruns out of parents, returnthis._mainFrameSession. With that change the repro passes:page.url()is correct andtitle()resolves. Reverting it brings the hang back.Field data. This comes from my own Chrome 157.0.8103.52 on Windows 11, where I first hit the hang. The tab's URL and title are left out.
Runtime.executionContextCreatedarrives for the main frame id, for both the default and the utility world, and thetitlecall on that frame never gets an answer.chrome://discardsrow for that tab: Visibility hidden, Loading State loaded, Lifecycle State hidden, Discardable no, Freezable yes, Discard Count 0.chrome://process-internals: Site Per Process, 58 renderer processes, limit 82, not over the limit.pw-489-repro.mjs
npm i playwright-core && node pw-489-repro.mjs. Use--no-listfor the control run, and--holdto keep Chrome running so you can tryplaywright-cli attach --cdp=http://127.0.0.1:9350.Since this now reproduces, could the issue be reopened?
cyppe commentedon Nov 21, 2026
This matches what we see. Environment: Linux (Arch), Chromium 155.0.8059.84, playwright-core 1.65.0, @playwright/cli 0.1.23, attaching to a long-running headed browser.
The symptom is the same: one tab sits half-initialised (main frame url
"", load statecommitonly),Tab.headerSnapshot()waits onpage.title()forever, andattachand every later command in that session hang. In 1.65.0 thatpage.title()call still has no deadline. We work around it locally by bounding it with a short timeout, and the hang has not come back since.Since there is now a deterministic reproduction above, could this be reopened?