#3543·vinext

App Router: `BrowserRoot` writes its router-state ref during render, so an aborted navigation's uncommitted payload seeds the next navigation

Author: quantizorCreated Sep 28, 2026Updated Sep 28, 2026

Summary

BrowserRoot in dist/server/app-browser-entry.js writes its router-state ref during render. The navigation controller reads that ref as the base of the next navigation. When a navigation is superseded while its RSC body is still streaming, the transition React rendered for it, but never committed, becomes the base of the next navigation. Its aborted stream then rejects inside the new commit and trips the route's error boundary, and the boundary can't recover on the same path.

This corrects the diagnosis in #3130. That issue attributed the failure to a superseded router.refresh(). A refresh isn't required: two ordinary navigations to the same path reproduce it, and the refresh variant alone never tripped a boundary in testing.

Root cause

javascript
// dist/server/app-browser-entry.js, BrowserRoot
const treeState = isRouterStatePromise(treeStateValue) ? use(treeStateValue) : treeStateValue;
const stateRef = useRef(treeState);
stateRef.current = treeState; // written during render, not on commit

getBrowserRouterState() returns stateRef.current, and dist/server/app-browser-navigation-controller.js builds each navigation on it (including dispatchApprovedVisibleCommit). In concurrent React a render isn't a commit, so a ref written during render can hold state from a tree that never reached the screen.

Sequence

  1. Navigation A receives its response headers. Its top-level payload is approved and a transition is dispatched while the body is still streaming.
  2. Navigation B to the same path calls abortSupersededNavigation(). A's stream rejects with AbortError: BodyStreamBuffer was aborted (Chrome's wording).
  3. B commits on top of A's leaked elements, and the abort surfaces in the page slot.
  4. The error boundary only resets on a pathname or reset-key change (shouldResetBoundary in dist/shims/error-boundary.js). On the unchanged path it stays tripped, and each reset() re-renders the same committed state and throws again.

Reproduction

  1. Any App Router app with a link to a route whose RSC response streams for a moment.
  2. Throttle the network (CDP Network.emulateNetworkConditions, about 40 KB/s download, 20 ms latency).
  3. Click the link. When the first RSC response's headers arrive, wait 380 to 460 ms, then click the same link again.
  4. The route's error boundary renders. Pressing its reset re-throws the same abort.

Observed: 15 of 15 attempts in that window.

Fix

Commit the ref after render:

javascript
const stateRef = useRef(treeState);
useLayoutEffect(() => {
  stateRef.current = treeState;
});

Declared before BrowserRoot's other layout effects, this took the same reproduction to 0 of 15. It runs here as a local patch on 1.0.0-beta.4. The render-time write is unchanged in 1.0.0.

Why it can blank the page on React 19.2

With the abort thrown during a transition, BrowserRoot matches facebook/react#33580. It is hydrated with hydrateRoot, it calls use() only while its state is a promise, and it calls useRef unconditionally after that. React 19.2.x reports error #310 ("Rendered more hooks than during the previous render") above every app boundary and unmounts the root, which leaves a blank page. React 19.3 includes the fix (facebook/react#36911), and there the failure stays inside the route's boundary.

Related: a refresh cancels an in-flight navigation

refresh() in dist/shims/navigation.js skips only when a push is scheduled in the same task (hasScheduledAppRouterNavigation()). A refresh that arrives while a navigation is still streaming aborts that navigation and re-fetches the address being left. A background refresh on a timer or on window focus can therefore cancel a user's click. Skipping a refresh while a navigation is in flight would close it. I can file this separately if you'd prefer.

Environment

vinext 1.0.0-beta.4 (the ref write is also present in 1.0.0), React 19.2.7 and 19.3.0, Chrome.