Skip to content

fix(cli,engine): pin the page server's direct host to an explicit port and the Studio's own origin - #7945

Merged
miguel-heygen merged 1 commit into
mainfrom
fix/cli-page-network-followups-2
Nov 16, 2026
Merged

miguel-heygen merged 1 commit into
mainfrom
fix/cli-page-network-followups-2

Conversation

@jrusso1020

Copy link
Copy Markdown
Collaborator

What

Review follow-ups to #7941:

  • Explicit port on the direct host. A restricted browser's page server goes into --proxy-bypass-list as hostname:port, with the port always written, through a new engine helper pageServerDirectHost. URL.host drops a scheme's default port, so a page server at http://localhost/ gave the entry localhost, which Chrome reads as every port on that host. It now gives localhost:80.
  • Studio thumbnails use the server's own origin. The thumbnail browser's page server is the Studio server's origin when it has one, never the host a request names. The browser is reused per origin, so localhost:4100 and 127.0.0.1:4100 no longer close each other's browser.
  • A stop while the profile is being made. The release now waits for the temp profile being created and removes it. launchWithPageNetwork then refuses to launch Chrome, so a Ctrl-C at that moment leaves no profile behind.
  • A stricter wiring test. It matches the called name, so engine.acquireBrowser(…) counts. It flags any import or destructuring that renames a watched function. A launchWithPageNetwork callback must pass on both network.args and network.userDataDir. A pageServerUrl of undefined, null or void counts as missing.

Why

From the reviews of #7941: a bypass entry with no port widens the direct host to the whole host, a request's Host header could pick the thumbnail page's direct host, a stop that lands during profile creation leaks that profile, and the wiring test checked only where a launch sat, not whether it used the fence.

Related work

Refs #7941, #7935

How

  • pageServerDirectHost(url) in @hyperframes/engine/public-network returns hostname:port, filling in 80 or 443. The engine's pool browser (createBrowserLaunchFingerprint) and the CLI helper both use it.
  • launchWithPageNetwork keeps the profile's promise. The memoized release awaits it before removing the folder, and a launch that finds the release already ran throws instead of starting Chrome.
  • getThumbnailBrowser takes options.origin?.() ?? previewUrl and keys reuse on new URL(…).origin.

Test plan

  • fails without the fix: browserManager.test.ts "names the page server's port even when the URL leaves out the default". http://localhost/ gave localhost; now localhost:80, 127.0.0.1:443 and [::1]:4321.

  • fails without the fix: pageNetwork.test.ts "names the page server's port in the bypass entry even when the URL leaves it out".

  • fails without the fix: pageNetwork.stop.test.ts. The profile creation is held until the stop cleanup has started. On main the profile stays on disk; with the fix it's removed and Chrome isn't launched.

  • fails without the fix: studioServer.test.ts "gives the thumbnail browser the server's own origin, whatever host a request named". Three requests naming 127.0.0.1:4100, localhost:4100 and localhost:9999 launch one browser with pageServerUrl: http://127.0.0.1:4100.

  • fails without the fix: pageNetwork.wiring.test.ts with ...network.args removed from layout.ts. The positive control now also covers a namespace call, pageServerUrl: undefined, a renamed import, a renamed destructuring and a callback that drops network.args.

  • CLI src/browser/, studioServer.test.ts and the real-Chrome captureCompositionFrame.pageNetwork.browser.test.ts with chrome-headless-shell 157: 297 pass. Engine browserManager.test.ts and publicNetwork: 197 pass. The pre-commit hook passes (typecheck, lint, format, fallow), and so do the comment citation and ratchet checks.

  • Not exercised: a real Studio session with the flag on.

  • Unit tests added/updated

  • Manual testing performed

  • Comments follow CONTRIBUTING.md "Comments"

— Rames Jusso (hyperframes)

🤖 Generated with Claude Code

…t and the Studio's own origin

The bypass entry for a restricted browser's page server now always names its
port, so a default port no longer admits every port on the host. Studio
thumbnails take the server's own origin, not a request's Host header. A stop
signal that lands while the temp profile is being made removes it and launches
no Chrome. The wiring test follows renamed and namespaced calls, requires the
callback to pass on the network's args and profile, and refuses an unset
pageServerUrl.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@vanceingalls vanceingalls left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved at 92b2660. All the #7941 notes are addressed:

  • pageServerDirectHost fills in 80/443 and keeps an explicit port and IPv6 brackets. Both bypass sites (CLI pageNetwork, engine browserManager) use it.
  • The thumbnail direct host is pinned to the Studio server's own origin.
  • A stop during profile creation skips the Chrome launch and removes the profile. The test asserts both.
  • The wiring test follows namespace imports and renames, and treats undefined/null pageServerUrl as missing.
  • localhost vs 127.0.0.1 fails closed: the other spelling still goes through the proxy and is refused.
    Merge once the pending checks are green.

Non-blocking:

  • launchCaptureBrowser.ts:58 still uses new URL(localOrigin).host. It's safe today, since localPage writes 127.0.0.1:, but route it through pageServerDirectHost so the default-port case can't come back.
  • A stop that lands while Chrome is launching, after the profile exists, still leaves that browser running (pre-existing).
  • The wiring test misses const f = launchManagedBrowser aliases and computed engine["acquireBrowser"] calls.

@github-actions

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 267 (base branch 267), smooth 103 of those

The gate passes.
Smoothness is reported in the artifact, not gated. A case fails only if it fails 2 of 3 runs.

Quarantined, measured but not gated (8)

Unstable (2)

  • seqplainkeys-none-pct-r0-nested-z100: tracking 0.05, pressJump 0, drop 0, reload 0, render 0.02, renderKey -, undo true, teleport true / tracking 0.05, pressJump 0, drop 0, reload 0, render 0.02, renderKey -, undo true, teleport true / tracking 0.05, pressJump 0, drop 0, reload 0, render 0.02, renderKey -, undo true, teleport true
  • seqfastkeys-none-px-r0-root-z100: tracking 0.06, pressJump 0.05, drop 0, reload 0, render 0.02, renderKey -, undo false, teleport true / tracking 0.06, pressJump 0.05, drop 0, reload 0, render 0.02, renderKey -, undo true, teleport true / tracking 0.06, pressJump 0.05, drop 0, reload 0, render 0.02, renderKey -, undo true, teleport true

@jrusso1020
jrusso1020 added this pull request to the merge queue Nov 16, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 16, 2026
@jrusso1020
jrusso1020 added this pull request to the merge queue Nov 16, 2026
@jrusso1020
jrusso1020 removed this pull request from the merge queue due to a manual request Nov 16, 2026
@jrusso1020

Copy link
Copy Markdown
Collaborator Author

Taken out of the merge queue at Miguel's request so the v0.9.58 release (#7932) can land first; any OSS merge before it forces another re-cut. Re-queue once 0.9.58 is on npm. — Rames

@miguel-heygen
miguel-heygen added this pull request to the merge queue Nov 16, 2026
Merged via the queue into main with commit dbc9c18 Nov 16, 2026
93 checks passed
@miguel-heygen
miguel-heygen deleted the fix/cli-page-network-followups-2 branch November 16, 2026 17:06
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.

3 participants