Skip to content

fix(routing): throw on unbalanced braces in route glob patterns#40614

Merged
pavelfeldman merged 2 commits intomainfrom
copilot/fix-unbalanced-brace-glob
May 4, 2026
Merged

fix(routing): throw on unbalanced braces in route glob patterns#40614
pavelfeldman merged 2 commits intomainfrom
copilot/fix-unbalanced-brace-glob

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 4, 2026

Globs with unbalanced { / } passed to page.route() produced an invalid regex inside globToRegexPattern. The SyntaxError was raised lazily at request-match time, silently aborting matched requests and timing out navigations with ERR_ABORTED.

await page.route('http://*/foo{', route => route.continue());
await page.goto('http://localhost:1234/'); // hangs, then ERR_ABORTED

Changes

  • packages/isomorphic/urlMatch.tsglobToRegexPattern now throws a descriptive error on unmatched {, unmatched }, and nested { instead of emitting an unterminated regex group.
  • packages/playwright-core/src/client/network.tsRouteHandler and WebSocketRouteHandler constructors eagerly call resolveGlobToRegexPattern for string globs, so invalid patterns surface at the page.route() / page.routeWebSocket() (and BrowserContext equivalents) call site rather than at request-match time.
  • tests/page/interception.spec.ts — coverage for the new validation and for page.route() rejecting on an invalid glob.

Escaped braces (\\{, \\}) remain literal and unaffected.

Copilot AI changed the title [WIP] Fix unbalanced brace in route glob to prevent navigation abort fix(routing): throw on unbalanced braces in route glob patterns May 4, 2026
Copilot AI requested a review from pavelfeldman May 4, 2026 22:13
@pavelfeldman pavelfeldman merged commit 628d858 into main May 4, 2026
41 of 43 checks passed
@pavelfeldman pavelfeldman deleted the copilot/fix-unbalanced-brace-glob branch May 4, 2026 23:39
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.

page.route() silently aborts navigation when glob contains unbalanced { or }

3 participants