Skip to content

Strip profile session restore when configure batch carries a start_url - #339

Open
yummybomb wants to merge 2 commits into
mainfrom
hypeship/start-url-profile-tab-race
Open

Strip profile session restore when configure batch carries a start_url#339
yummybomb wants to merge 2 commits into
mainfrom
hypeship/start-url-profile-tab-race

Conversation

@yummybomb

@yummybomb yummybomb commented Aug 17, 2026

Copy link
Copy Markdown

Summary

When /chromium/configure receives both a profile archive and a start_url, the documented behavior is that start_url wins: the browser should come up on that page with the profile's saved tabs discarded. Today that override is racy. The profile archive keeps Default/Sessions (intentionally, so tab restore works when no start_url is given), and Chrome restores those tabs asynchronously after DevTools comes up. DispatchStartURL enumerates page targets right after DevTools readiness, closes the extras it sees, and navigates the first — so any restored tab that materializes after that enumeration survives and can leave the browser sitting on a profile tab instead of the requested page.

Fix: when the configure batch carries a start_url, delete Default/Sessions from the extracted profile before installing it. With no session-restore data on disk, Chrome never reopens the old tabs and there is nothing to race. This mirrors what the legacy-profile migration path in the API already does for the same reason.

Scope notes:

  • Only the live copy in the VM is touched; the stored profile archive is unchanged, and cookies/local storage are preserved.
  • When no start_url is present, Default/Sessions is kept and tab restore behaves exactly as before.

Testing

  • go test ./cmd/api/api/ -count=1 passes (includes new TestStripProfileSessionRestore).
  • go vet ./cmd/api/api/ clean.
  • e2e suite not run locally (needs docker); the existing /chromium/configure powerset e2e covers the profile+start_url combination path.

Note

Low Risk
Narrow change on the profile install path, gated on start_url; behavior without start_url is unchanged.

Overview
When /chromium/configure installs a profile archive and a start_url, the handler now removes Default/Sessions from the extracted profile before install so Chrome cannot asynchronously restore saved tabs and race DispatchStartURL.

Profile-only configures are unchanged: session data stays on disk and tab restore still works. Only the live VM copy is modified; the uploaded archive is untouched.

Adds stripProfileSessionRestore and TestStripProfileSessionRestore (removes Sessions, leaves other profile files, no error if Sessions is missing).

Reviewed by Cursor Bugbot for commit aa17d7b. Bugbot is set up for automated code reviews on this repo. Configure here.

@yummybomb
yummybomb marked this pull request as ready for review August 17, 2026 21:51
@yummybomb
yummybomb requested a review from hiroTamada August 18, 2026 19:07
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.

2 participants