Skip to content

fix(react-router): discard fetcher reloads for abandoned navigations - #15740

Open
EpicHigh wants to merge 5 commits into
remix-run:mainfrom
EpicHigh:fix/abandoned-fetcher-navigation-reloads
Open

EpicHigh wants to merge 5 commits into
remix-run:mainfrom
EpicHigh:fix/abandoned-fetcher-navigation-reloads

Conversation

@EpicHigh

@EpicHigh EpicHigh commented Nov 6, 2026 •

Copy link
Copy Markdown

A fetcher action can start revalidating a pending navigation that is subsequently abandoned. When that reload finishes before the newer navigation, it currently commits results for the abandoned URL: current loader data disappears, errors can replace the current form, and redirects can cancel the newer navigation.

Reproduction in the first commit:

  1. Submit a fetcher action while /current remains visible.
  2. Start navigating to /previous before the action resolves.
  3. Resolve the action, starting its reload of /previous.
  4. Navigate to /next, abandoning /previous.
  5. Finish the action's older reload while /next is still pending.

The Framework Mode browser tests hold single-fetch responses to force this ordering and verify that an unsaved form stays mounted for data, error, and redirect responses. All three fail on base db80dda076ec9cdcefff480079252fe0c977710e. Of 28 focused router cases, 24 fail on that base and four controls pass.

Review found that POP and explicit revalidation can restart navigation with the same location key. Twelve added router cases fail on the previous PR head 12da380, and three added browser cases also fail there. The final focused file has 42 cases, including unmount cleanup controls, and the browser fixture has six cases covering preservation of the draft and legitimate errors/redirects from the latest request.

The reload retains the controller of the navigation it is reloading. A reused location key therefore cannot make a superseded navigation look active. Results for an abandoned destination are discarded, while reloads of the displayed pathname/search remain allowed. The completed action result is preserved, and only secondary fetchers still owned by that reload are settled, including controller-free 404 results after HMR. This preserves the existing “commits both” behavior.

This affects the shared client router used by Data and Framework modes.

Related work:

Validation on d2af1917a401b7c7af1e78d4ae44d1c991e4ecb6:

  • pnpm test packages/react-router/ --runInBand: 125 suites, 2,967 tests and 824 snapshots pass; 15 existing skips.
  • pnpm test:integration:run integration/fetcher-abandoned-navigation-test.ts --project chromium --workers 1 --retries 0 --reporter line: all six pass after the fix.
  • pnpm build, package and integration typechecks, scoped ESLint and Prettier checks pass. ESLint reports only two warnings also present on unmodified upstream.

The full integration suite and other browser engines were not run.

Upstream CI for this exact head is awaiting maintainer approval before it can run: Unit Test. The results above are local validation.

@EpicHigh
EpicHigh force-pushed the fix/abandoned-fetcher-navigation-reloads branch from 75129ff to 12da380 Compare November 6, 2026 15:03
@EpicHigh
EpicHigh marked this pull request as ready for review November 6, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants