Skip to content

fix: honor Fetch.enable urlPattern patterns - #6

Open
lgwacker wants to merge 3 commits into
VulpineOS:mainfrom
lgwacker:fix/fetch-enable-patterns
Open

fix: honor Fetch.enable urlPattern patterns#6
lgwacker wants to merge 3 commits into
VulpineOS:mainfrom
lgwacker:fix/fetch-enable-patterns

Conversation

@lgwacker

Copy link
Copy Markdown

Fixes #5.

Problem

Fetch.enable with urlPattern patterns was translated to Juggler's Browser.setRequestInterception with only {enabled: true} — the patterns were dropped. Every request in the browser got intercepted (paused) instead of only pattern-matching ones, so clients that scope Fetch.enable to a single URL had all navigation requests paused forever: Page.navigate returned a navigationId but no frameNavigated ever fired, because non-matching requests waited for a Fetch.continueRequest that never came.

Changes

  • pkg/bridge/fetch.goFetch.enable now parses params.Patterns, extracts each entry's urlPattern, and stores the list per CDP session in Bridge.fetchPatterns (mutex-guarded, matching the existing per-map mutex pattern). No patterns → nil → intercept everything (unchanged behavior). Fetch.disable clears the entry. Added a globMatch(pattern, url) helper (glob * = any sequence, case-insensitive, anchored full-URL match).
  • pkg/bridge/events.go — the Browser.requestIntercepted handler now checks the session's patterns and auto-continues (Browser.continueInterceptedRequest) any request whose URL matches no pattern, skipping Network.requestWillBeSent/Fetch.requestPaused for it. Matching requests (or sessions with no patterns) keep the current pause-and-emit path.
  • pkg/bridge/bridge.go — added fetchPatternsMu/fetchPatterns fields and map init.

Verification

  • go build passes (golang:1.26 container) and gofmt -l is clean.
  • Behavior matrix:
    • No patterns → every request paused (unchanged).
    • Patterns + URL matches → paused and emitted.
    • Patterns + URL doesn't match → auto-continued, navigation proceeds.

Notes

  • Pattern matching mirrors Chrome semantics: glob-style *, case-insensitive, full-URL match.
  • This only affects sessions that pass explicit patterns; sessions using bare Fetch.enable are unaffected.

@lgwacker
lgwacker marked this pull request as draft August 12, 2026 18:57
The previous fix only patched Fetch.enable patterns into the
Browser.requestIntercepted handler, but that event does not exist in
the Juggler protocol. Requests are paused via the per-page
NetworkObserver, which emits Network.requestWillBeSent with an
isIntercepted flag.

- Fetch.enable -> Network.setRequestInterception (page session)
- Fetch.continueRequest -> Network.resumeInterceptedRequest
- Fetch.fulfillRequest -> Network.fulfillInterceptedRequest
- Fetch.failRequest -> Network.abortInterceptedRequest
- emit Fetch.requestPaused from Network.requestWillBeSent when
  isIntercepted is set; auto-continue non-matching patterns
Verified against Camoufox 135 (omni.ja): enabling Network.setRequestInterception pauses every request (channelIntercepted stores them in _interceptedRequests) but PageNetwork.Events.Request is never delivered to the PageHandler in the browser process — no Network.requestWillBeSent, no isIntercepted, nothing resumes the paused requests. Navigation stalls forever (Page.navigate returns navigationId, frameNavigated never arrives).

Fetch.enable is now a no-op (patterns still remembered for a future Juggler fix): dialog interception is degraded, but pages load. This unblocks every CDP client that enables Fetch (e.g. Hermes dialog-bridge supervisor).
@lgwacker
lgwacker marked this pull request as ready for review August 12, 2026 21:12
@lgwacker

Copy link
Copy Markdown
Author

FYI — the complete fix set now lives on lgwacker/foxbridge main (c1f51a8): this PR's Fetch fix, plus the main-frame Runtime.evaluate context fix (issue #7) and the --host bind flag (issue #8), all as commits. hermes-foxbridge builds its sidecar binary from that fork. Happy to split the other two into their own PRs if you'd like.

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.

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

1 participant