Skip to content

Conversation

@zerone0x
Copy link

Summary

Fixes #187

  • Removes the URL filter that excluded pages with empty URLs during CDP connection
  • Updates test to verify pages with empty URLs are now included

Changes

  • src/browser.ts: Remove .filter((page) => page.url()) from CDP connection code
  • src/browser.test.ts: Update test to expect all pages including those with empty URLs

Problem

When connecting to an Electron app via CDP (--cdp flag), the connection fails with "No page found" even when the Electron window is open and has content loaded.

The root cause was that Electron apps often have pages with empty URL strings ("") during initialization. The filter .filter((page) => page.url()) excluded these because empty strings are falsy in JavaScript.

Solution

Remove the URL filter to allow all valid pages from browser contexts. The validation if (allPages.length === 0) still ensures at least one page exists.


🤖 Generated with Claude Code

…upport

Electron apps often have pages with empty URLs during initialization or
with file:// URLs. The previous filter `page.url()` excluded these pages
because empty strings are falsy in JavaScript, causing "No page found"
errors when connecting to Electron apps via CDP.

This change removes the URL filter to allow all valid pages from browser
contexts, enabling agent-browser to work with Electron apps.

Fixes vercel-labs#187

Co-Authored-By: Claude <noreply@anthropic.com>
@vercel
Copy link
Contributor

vercel bot commented Jan 21, 2026

@zerone0x is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

const allPages = contexts.flatMap((context) => context.pages()).filter((page) => page.url());
// Get all pages from all contexts - don't filter by URL as Electron apps
// may have pages with empty URLs during initialization
const allPages = contexts.flatMap((context) => context.pages());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling getCDPSession() on a page with empty URL causes Playwright to hang indefinitely, reintroducing the issue from #102 that was fixed but then regressed when the filter was removed to support Electron apps.

Fix on Vercel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CDP connection fails for Electron apps due to strict URL filter

1 participant