Repository navigation
Resolve a page's relative request against its base, as the browser does - #1564
Open
rudycelekli wants to merge 1 commit into
Open
rudycelekli wants to merge 1 commit into
rudycelekli wants to merge 1 commit into
Conversation
The page network hook resolved fetch() and XMLHttpRequest.open() addresses against location.href. The browser resolves them against document.baseURI, which a <base href> moves, so on such a page the recorded url, route and origin named an address that was never requested.
rudycelekli
requested review from
MikeRyanDev,
davidmckayv,
dustywusty,
guidovizoso,
mxmzb,
samjulien and
tylerslaton
as code owners
November 13, 2026 17:12
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
In page mode, the Recorder can record a request at an address the page never called.
When Chrome refuses the debugger, the Recorder falls back to page mode and injects
extension/src/main-world/network-hook.tsinto the page. The hook wrapsfetchandXMLHttpRequest.openand records each request's address withabsolute(url), which isnew URL(url, location.href). The browser resolves a relative address againstdocument.baseURIinstead, and a<base href>element moves that away from the page's own address. On a page with one, the recordedurl,routeandoriginname a request that was never made.Example: on
https://shop.example.com/app/orders/42with<base href="/">, which Angular apps set by default and whose HttpClient calls are often written asapi/...,fetch("api/orders/42/archive")goes tohttps://shop.example.com/api/orders/42/archive. The hook recordedhttps://shop.example.com/app/orders/api/orders/42/archive. A<base href>on another origin gets the origin wrong too.That value is the step's network exchange. It feeds the step's save request, the repeat signature, and
matchRun/matchRuntimeInfoRequest, so the recording describes an endpoint that doesn't exist. In debugger mode CDP reports the real URL, so the same page records different addresses depending on which mode Chrome allowed.The fix resolves against
document.baseURI, which is whatfetch()andXMLHttpRequest.open()use. A page without<base>hasdocument.baseURI === location.href, so nothing changes for it.Where it runs
OpenBot is deployed as several server processes behind a load balancer, serving a whole company.
Consecutive requests from the same person reach different processes, and the process that answered a
WebSocket upgrade is rarely the one that answers the next call on that conversation.
State that outlives a single request therefore has to be shared, or the change works on one machine
and stops working the moment there are two, without saying so. That failure is worse than not
shipping the feature: it passes review, passes CI, passes a local demo, and only surfaces as a Bot
that forgets, a question nobody can answer, or a boundary that never fires.
Answer these even when the answer is "none":
Postgres is already there and is the default answer to all of the above: a table, a unique index, a
conditional update,
LISTEN/NOTIFYfor fan-out.Boundary and audit
Changelog
CHANGELOG.mdunderUnreleased, at the top of Smaller changes:Proof
New test in
extension/tests/page-network-hook.test.ts,a relative address is recorded where the browser sends it, under the page's <base href>. The happy-dom page at/pagegets<base href="/api/">. Itsfetchresolves againstdocument.baseURIthe way a browser's does.fetch("small")must then be recorded with route/api/smalland urlhttp://127.0.0.1:<port>/api/small.Rebuilt on
mainatf8af37ab. With only the source change reverted (git checkout origin/main -- extension/src/main-world/network-hook.ts), the new test fails:With the fix:
Gates:
bunx biome formatandbunx biome lint --error-on-warningson the touched files report nothing.cd extension && bun run typecheck(tsc --noEmit) exits 0.