Skip to content

Fetch.enable ignores urlPattern patterns — intercepts every request and stalls navigation #5

Description

@lgwacker

Bug description

Fetch.enable with a patterns array of urlPatterns is translated to Juggler's Browser.setRequestInterception with only {enabled: true} — the URL patterns are dropped entirely. As a result, every request in the browser is intercepted (paused) instead of only the requests matching the requested patterns.

Root cause

In pkg/bridge/fetch.go, the Fetch.enable handler parses params.Patterns but never uses it; it only forwards {"enabled": true} to Juggler. Juggler has no pattern support of its own, so the bridge must implement the pattern filtering — but it currently doesn't, and the Browser.requestInterceptedFetch.requestPaused handler in pkg/bridge/events.go emits a paused event for every intercepted request.

Impact

Any client that scopes Fetch.enable to a single URL (e.g. a dialog-bridge supervisor intercepting only http://hermes-dialog-bridge.invalid/*) gets all navigation requests paused forever:

  • Page.navigate returns a navigationId, but the page never commits — no frameNavigated is ever emitted.
  • Every request waits for a Fetch.continueRequest that the client will never send (it only handles requests matching its pattern).
  • Navigation stalls indefinitely; the only way out is disabling interception entirely.

Repro steps

  1. Start foxbridge and connect a CDP client (e.g. Puppeteer) to a Firefox/Camoufox instance.
  2. Call Fetch.enable with a single pattern, e.g. {"patterns": [{"urlPattern": "http://hermes-dialog-bridge.invalid/*"}]}.
  3. Call Page.navigate to any other URL (e.g. https://example.com).
  4. Observe: the navigation request is paused and Fetch.requestPaused is emitted for it (matching the pattern or not), Page.navigate returns a navigationId, but frameNavigated never fires and the page never loads.

Expected vs actual

  • Expected (Chrome semantics): only requests matching at least one urlPattern are paused; all other requests are transparently continued.
  • Actual: every request is paused and waits for a continuation that never comes.

Fix approach

  • Keep the per-CDP-session urlPattern list from Fetch.enable (and clear it on Fetch.disable).
  • In the Browser.requestIntercepted handler, auto-continue (Browser.continueInterceptedRequest) any request whose URL matches no pattern, and only emit Network.requestWillBeSent / Fetch.requestPaused for matching requests.
  • Pattern matching mirrors Chrome: glob where * matches any sequence, case-insensitive, anchored to the full URL.
  • Fetch.enable with no patterns keeps the current behavior (intercept everything).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions