Skip to content

[browse] Auth state is lost across separate invocations; next call restarts on about:blank with stale state #778

Closed

Description

@robertDouglass

Summary

The browse daemon can lose its authenticated browser context across separate CLI invocations. In my case, a login succeeds inside one browse chain call, but the next independent browse call starts a fresh server/session on about:blank and the authenticated state is gone.

A related symptom is that .gstack/browse.json can still exist with a PID, but that PID is already dead by the time the next command runs.

Environment

  • gstack version: 0.15.2.1
  • gstack commit: c620de38e19fe63e8a6e361e11d706b5ed432b93
  • OS: macOS 15.6 (Darwin 24.6.0), arm64
  • Install mode: global install under ~/gstack, using the compiled browse binary
  • Working directory: project-local state under <repo>/.gstack/

Repro

  1. From a repo directory, run browse chain against an authenticated site login flow.
  2. In the same chain call, navigate to the login page, take a snapshot, fill username/password, and click the primary sign-in button.
  3. Confirm the login succeeds and browse lands on an authenticated page.
  4. Run a later independent command from the same cwd, for example browse url or browse text.

Observed

  • The login succeeds inside the original chain call.
  • On the next independent invocation, browse prints [browse] Starting server... again and returns about:blank instead of the previously authenticated page.
  • Navigating back to the app after that lands on the public/unauthenticated experience, so the session cookie/context appears lost.
  • .gstack/browse.json may still be present even though the PID inside it is no longer alive.

Expected

  • Separate browse invocations from the same cwd should reconnect to the same live daemon/browser context while it is healthy.
  • If the daemon is gone, the failure mode should either preserve persisted session state or at least cleanly invalidate stale state instead of silently starting a fresh blank session that looks healthy but has lost auth.

Concrete output

Successful login inside one chain call:

[click] Clicked @e8 → now at https://spec-kitty-dev.fly.dev/a/robert-team/dashboards/
[url] https://spec-kitty-dev.fly.dev/a/robert-team/dashboards/

Next independent invocation from the same cwd:

$ browse url
[browse] Starting server...
about:blank

After navigating back to the same host in that fresh session, I get the public home page rather than the authenticated dashboard.

Notes

  • I reproduced this against a Fly.io-hosted Django app with cookie auth.
  • browse chain is usable as a workaround because it keeps the whole flow inside one daemon run.
  • This looks like either an unexpected daemon exit between invocations, stale browse.json handling, or missing persistence of the browser profile/session store across restarts.

Activity

  1. time-attack commented on Jul 15, 2026

    @time-attack
    Contributor

    @16francej Please close this issue as resolved. The browser daemon now survives separate shell commands through the detached lifecycle implementation in #1612, preserving pages and auth state between calls.

  2. garrytan commented on Aug 15, 2026

    @garrytan
    Owner

    Fixed in fork-port wave 2: opt-in session persistence. Set BROWSE_PERSIST_STATE=1 in the daemon's environment and it snapshots cookies + per-tab URL/localStorage/sessionStorage to <stateDir>/session-state.json (0600) on an interval and at clean shutdown, then restores on the next launch — auth survives daemon restarts instead of coming back on about:blank.

    Commit: 80943401 feat(browse): opt-in session persistence — auth survives daemon restarts (#778, #2193)
    Pinned by: browse/test/session-persist.test.ts

    Ships in #2577 (v1.65.0.0).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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