Skip to content

Runtime.evaluate after a click-driven navigation fails with "Cannot find default execution context" #2187

@krichprollsch

Description

@krichprollsch

A Runtime.evaluate issued (without contextId) right after a click that triggers a same-tab navigation fails with Cannot find default execution context. Chrome handles the same
script. Affects Puppeteer / chromedp / playwright code that does page.evaluate(...) immediately after page.click(<link>).

Reproduction

await page.goto('https://demo-browser.lightpanda.io/', { waitUntil: 'networkidle0' });
await page.click("a[href='campfire-commerce/']");
const res = await client.send('Runtime.evaluate', { expression: '1+1' });
  • Chrome → {"result":{"type":"number","value":2}}
  • Lightpanda → ProtocolError: Protocol error (Runtime.evaluate): Cannot find default execution context

CDP trace around the click

Input.dispatchMouseEvent (mouseReleased)
< Runtime.executionContextsCleared ← old default destroyed
< Page.frameStartedNavigating
< Page.frameStartedLoading
< Network.requestWillBeSent
Runtime.evaluate {"expression":"1+1"}
< error: "Cannot find default execution context"

No Page.frameNavigated / Runtime.executionContextCreated between the cleared event and the evaluate.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions