fix(preview): retain crashed tabs for explicit recovery #21980
main fromrefs/pull/21980/head·opened View on GitHubSummary#
A renderer crash silently removes its browser tab. The user loses the tab instead of seeing the failure and choosing how to recover it.
renderer crash
- drop the logical tab
+ retain its identity and report LoadFailed
+ dispose failed native resources
explicit Reload or navigation
+ create a replacement page and reconnect viewers
intentional close
remove the tab
Keep the session, URL, settings and control owner. Failed-page agent operations return a typed crash error. Recovery preserves healthy tabs sharing the profile; late callbacks cannot publish stale page state in the covered scenarios.
Web already consumes LoadFailed through its existing failure UI and recovery stream. Mobile now passes the failure description into its existing overlay, supplies a nonempty fallback and enables controlled Reload before frames resume. No shared contract change is needed.
Scope and approval#
Issue #21022 and maintainer acceptance establish the silent deletion defect and the intended retained crash state. That acceptance does not approve this implementation or promise a merge.
This fixes T3's crash lifecycle. It does not fix Chromium's native BadgeService cause, intercept service workers, change Chromium builds or add automatic retries.
Evidence#
- Before, a service regression on the base emitted closed, returned an empty tab list and produced PreviewAutomationTabNotFoundError after a fake native crash. Suppressing the fake cleanup close event still reproduced deletion.
- After, the same service path retains the tab, reports LoadFailed and a typed execution error, and recovers the same identity on explicit Reload/navigation. Focused lifecycle cases also cover shared-context teardown, queued recovery versus close, pending downloads/choosers, stale callbacks, capacity and fake desktop reattachment.
- The final focused run passed 156 tests across ServerBrowser, Manager, ServerBrowserStream, SessionControl, PreviewAutomationBroker and client-runtime serverBrowserStream. Server and mobile package typechecks, four-file lint, formatting and git diff --check passed. Server typecheck prints existing Effect suggestions.
- These tests exercise real service/manager/broker/control logic with fake native boundaries.
- Real Windows headless renderer crash through a local service-worker badge fixture: web retained the failure, Reload and navigation recovered, and a healthy sibling remained usable. Android15 first opened the already-failed tab before healthy frames, showed the failure and enabled Reload. Tapping Reload restored the streamed fixture; a second crash after streaming also retained the failure.
Mobile before/after#
The base mobile UI and corrected UI below use the SAME fixed backend's retained LoadFailed state. The base UI shows Connecting and disables Reload; the corrected UI shows the crash and enables recovery. Both mobile files were restored to the PR commit after capture. This isolates the mobile rendering change; the service regression above establishes old-server deletion behavior.
| Base mobile UI | Corrected mobile UI |
|---|---|
Android recovery from retained crash to a working page, 10.6 seconds:
https://github.com/user-attachments/assets/cc6d55ec-1df5-46f7-8551-6f1dcfebb675
Reproduction: use the service-worker badge trigger reported in #21022 in the headless server browser, observe the failure, then choose Reload or navigate. For the captures I served a local fixture on127.0.0.1:18765 whose button sends one message to a service worker calling navigator.setAppBadge(3). The call only happens on that button press, so Reload does not retrigger the crash automatically. The backend used isolated synthetic data on13773; Android connected through10.0.2.2.
The Android APK was built from unchanged source in a short Windows checkout with a local CMake3.31.6/Ninja1.12.1 selection after normal ensure failed on Windows paths/Ninja. No dependency source patch. Real Electron guest recovery and iOS were not tested. The real crash supplies a nonempty description, so it does not exercise the empty-description fallback. SwiftLint, ktlint and detekt were unavailable.
Focused test command
vp test run apps/server/src/preview/ServerBrowser.test.ts apps/server/src/preview/Manager.test.ts apps/server/src/preview/ServerBrowserStream.test.ts apps/server/src/preview/SessionControl.test.ts apps/server/src/mcp/PreviewAutomationBroker.test.ts packages/client-runtime/src/preview/serverBrowserStream.test.ts
vp run --filter t3 typecheck
vp run --filter @t3tools/mobile typecheck
Merge Danger#
Door: two-way
Revert the scoped code change; no migration or protocol change.
Blast Radius: preview
Server-browser lifecycle and resource cleanup affect web, desktop and remote/mobile viewers. Mobile also changes the existing LoadFailed overlay and Reload gate. Real Electron recovery and the remaining low review concerns still need assessment.
Code and local packaging by Codex GPT-6.1 Sol through T3 Code / Codex harness. Independent Spec and Standards reviews by MiMo.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
tanstack-source added labelsbug
github-actions[bot](GitHub profile, opens in a new tab) added labelsneeds-rebase
Note
🤖 Claude Opus 5.5 responding on behalf of Theo
Closing. This PR has been open for more than 3 weeks, and
mainhas moved a long way since then. If the change still matters, open a fresh PR from currentmain.t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
This PR conflicts with
main. Rebase it or mergemaininto it. If it still conflicts after 7 days with no activity, it will be closed automatically.See the conflict window.