Skip to content

fix(router-core): remove navigation rollback - #8092

Open
Sheraff wants to merge 2 commits into
opencode/retained-pending-architecture-v5from
opencode/remove-all-rollback-v5
Open

fix(router-core): remove navigation rollback#8092
Sheraff wants to merge 2 commits into
opencode/retained-pending-architecture-v5from
opencode/remove-all-rollback-v5

Conversation

@Sheraff

@Sheraff Sheraff commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • replace publication rollback checkpoints with one-way, successor-owned navigation and HMR transactions
  • materialize redirects per lane, render redirect-target construction failures on the source route, and keep Solid/Vue link preloads on one location build
  • preserve structural pending ownership while hardening supersession, cancellation, boundary chunk failures, hydration handoff, and redirect reentrancy
  • update internal architecture documentation, regression coverage, and the router-core patch changeset

Failure Behavior Without Rollback

There is no catch-all that sends failures previously covered by rollback to the root error boundary. Failures now have distinct outcomes depending on where they occur.

Route-phase errors

Errors from route context, beforeLoad, loaders, validation, shouldReload, and component chunk loading are normalized into route outcomes. They call the originating route onError, mark the failing match as status: "error", and commit the new lane so that the route error boundary or default error component renders. The error belongs to the failing match; it is not automatically moved to the root match.

Relevant paths: packages/router-core/src/load-client.ts:313 and packages/router-core/src/load-client.ts:1166.

Updater errors

  • A direct router.navigate({ search: () => { throw ... } }) fails while buildLocation is running, before history or transaction publication. The returned promise rejects and the current presentation remains unchanged.
  • An updater that throws while materializing a loader or beforeLoad redirect is converted into an error on the redirect originating route. Its route error boundary renders.
  • A direct router.buildLocation call throws to its caller.

Relevant paths: packages/router-core/src/router.ts:2228 and packages/router-core/src/load-client.ts:1061.

Abort calls

A loader receives a loader-flight controller. If it calls .abort() and then returns data, that data is still accepted. If it throws afterward, the throw becomes a normal route error.

Route context, beforeLoad, and planning hooks receive the transaction controller. This controller is router-owned. Router-driven aborts are paired with a successor transaction: the obsolete lane releases its resources and the successor converges without restoring an older snapshot. Calling .abort() from userland without starting a successor is not a supported cancellation mechanism; it is not converted into a route error or root boundary.

Relevant path: packages/router-core/src/load-client.ts:621.

View-transition and publication errors

Errors from document.startViewTransition, a view-transition types updater, updateCallbackDone, or the framework startTransition wrapper are not converted into route errors. runClientTransaction rejects, and router.load() can reject. Depending on when the error occurs, the old matches may remain or the new matches may already be published. There is no rollback to the previous presentation.

These failures do not currently have a general publication finalizer: router status or the navigation commit promise can remain pending until a successor navigation takes ownership.

Relevant paths: packages/router-core/src/load-client.ts:1851 and packages/router-core/src/load-client.ts:1899.

Lifecycle and event errors

  • route.onError participates in route-error normalization. If it throws, the replacement value is normalized as the route outcome.
  • onEnter, onStay, and onLeave run after the new matches have been committed. If one throws, the exception escapes publication; it is not rolled back or converted into a route boundary, and finalization can remain incomplete.
  • Router event subscribers such as onLoad and onResolved are caught, logged, and ignored so later subscribers and navigations can continue.

Relevant paths: packages/router-core/src/load-client.ts:1650 and packages/router-core/src/router.ts:1370.

In short: expected loading failures become errors on the originating route, superseded work is discarded in favor of its successor, and pre-navigation construction errors reject before publication. View-transition and post-commit route lifecycle exceptions are intentionally not translated into root-boundary errors and currently have no generic terminal recovery path.

Testing

  • CI=1 NX_DAEMON=false pnpm nx run @tanstack/router-core:test:unit --outputStyle=stream --skipRemoteCache (1,589 passed, 3 expected failures)
  • CI=1 NX_DAEMON=false pnpm nx run @tanstack/react-router:test:unit --outputStyle=stream --skipRemoteCache (1,026 passed, 1 skipped)
  • CI=1 NX_DAEMON=false pnpm nx run @tanstack/solid-router:test:unit --outputStyle=stream --skipRemoteCache (864 passed, 1 skipped across client/server)
  • CI=1 NX_DAEMON=false pnpm nx run @tanstack/vue-router:test:unit --outputStyle=stream --skipRemoteCache (846 passed, 1 skipped)
  • type and ESLint targets for router-core, React, Solid, and Vue (zero errors; existing warnings only)
  • CI=1 NX_DAEMON=false pnpm nx run @tanstack/router-core:build --outputStyle=stream --skipRemoteCache
  • pnpm format and git diff --check

Bundle Size

Exact-base minimal gzip comparison: React +7 B, Solid +54 B, Vue +24 B.

@coderabbitai

coderabbitai Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7605cdde-0a27-48c9-9653-ded5365c237a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nx-cloud

nx-cloud Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit afc5b7c

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 7m 20s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 22s View ↗

☁️ Nx Cloud last updated this comment at 2026-08-17 06:19:53 UTC

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

2 package(s) bumped directly, 21 bumped as dependents.

🟩 Patch bumps

Package Version Reason
@tanstack/react-router 1.170.29 → 1.170.30 Changeset
@tanstack/router-core 1.171.24 → 1.171.25 Changeset
@tanstack/react-start 1.168.46 → 1.168.47 Dependent
@tanstack/react-start-client 1.168.27 → 1.168.28 Dependent
@tanstack/react-start-rsc 0.1.45 → 0.1.46 Dependent
@tanstack/react-start-server 1.167.34 → 1.167.35 Dependent
@tanstack/router-cli 1.167.30 → 1.167.31 Dependent
@tanstack/router-generator 1.167.30 → 1.167.31 Dependent
@tanstack/router-plugin 1.168.32 → 1.168.33 Dependent
@tanstack/router-vite-plugin 1.167.32 → 1.167.33 Dependent
@tanstack/solid-router 1.170.27 → 1.170.28 Dependent
@tanstack/solid-start 1.168.44 → 1.168.45 Dependent
@tanstack/solid-start-client 1.168.26 → 1.168.27 Dependent
@tanstack/solid-start-server 1.167.33 → 1.167.34 Dependent
@tanstack/start-client-core 1.170.24 → 1.170.25 Dependent
@tanstack/start-plugin-core 1.171.36 → 1.171.37 Dependent
@tanstack/start-server-core 1.169.28 → 1.169.29 Dependent
@tanstack/start-static-server-functions 1.167.29 → 1.167.30 Dependent
@tanstack/start-storage-context 1.167.26 → 1.167.27 Dependent
@tanstack/vue-router 1.170.26 → 1.170.27 Dependent
@tanstack/vue-start 1.168.43 → 1.168.44 Dependent
@tanstack/vue-start-client 1.167.29 → 1.167.30 Dependent
@tanstack/vue-start-server 1.167.33 → 1.167.34 Dependent

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 536bbc4382

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +2005 to +2007
// Preserve the settlement turn in which immediately completed background
// work can publish before callers resume from `load`.
.then(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Finalize the transaction when publication throws

When commit throws—for example, when an application onEnter, onStay, or onLeave callback throws inside commitMatches—this empty .then() propagates the rejection without finalizing the current transaction. router.load()/navigate() then rejects while the router remains pending and _commitPromise remains unresolved, even though the new matches may already have been published, leaving subsequent consumers with a permanently loading router. Preserve a rejection cleanup path that settles transaction state without necessarily rolling back the publication.

Useful? React with 👍 / 👎.

@github-actions

github-actions Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Benchmarks

  • Commit: dd7d0233aa48
  • Measured at: 2026-08-17T06:13:01.158Z
  • Baseline source: history:f97188fdb4c3
  • Dashboard: bundle-size history

The following scenarios have bundle-size changes compared with the baseline:

Scenario Current (gzip) Delta vs baseline Initial gzip Raw Brotli Trend
react-router.minimal 83.81 KiB -15 B (-0.02%) 83.68 KiB 262.60 KiB 73.03 KiB ▃▃▃▄██▆▃▃▂▂▁
react-router.full 87.31 KiB -10 B (-0.01%) 87.17 KiB 274.31 KiB 76.00 KiB ▄▄▄▅██▅▃▃▂▂▁
solid-router.minimal 33.14 KiB +21 B (+0.06%) 33.01 KiB 96.32 KiB 29.88 KiB ▆▇████▅▁▁▁▁▃
solid-router.full 37.98 KiB +38 B (+0.10%) 37.85 KiB 110.96 KiB 34.17 KiB ▆▇████▅▁▁▁▁▅
vue-router.full 55.11 KiB -3 B (-0.01%) 54.99 KiB 156.71 KiB 49.63 KiB ▁█████▆▄▄▄▄▄
react-start.minimal 96.70 KiB +79 B (+0.08%) 96.56 KiB 304.86 KiB 83.78 KiB ▄▄▄▄██▅▂▂▁▁▆
react-start.deferred-hydration 97.42 KiB +77 B (+0.08%) 96.58 KiB 306.21 KiB 84.43 KiB ▃▃▃▃██▅▃▃▁▁▆
react-start.full 99.86 KiB +54 B (+0.05%) 99.72 KiB 314.59 KiB 86.55 KiB ▄▄▄▄██▄▁▁▁▁▅
react-start.rsbuild.minimal 100.01 KiB +49 B (+0.05%) 99.84 KiB 315.21 KiB 86.28 KiB ▁▁▁▂███▃▃▁▁▆
react-start.rsbuild.minimal-iife 100.41 KiB +45 B (+0.04%) 100.25 KiB 316.15 KiB 86.63 KiB ▁▁▁▂███▂▂▁▁▆
react-start.rsbuild.full 103.33 KiB +45 B (+0.04%) 103.16 KiB 325.30 KiB 89.03 KiB ▁▁▁▂███▂▂▁▁▆
solid-start.minimal 45.95 KiB +89 B (+0.19%) 45.83 KiB 137.42 KiB 40.87 KiB ▇█████▄▁▁▁▁█
solid-start.deferred-hydration 49.03 KiB +76 B (+0.15%) 45.89 KiB 144.88 KiB 43.66 KiB ▇▇████▄▁▁▁▁█
solid-start.full 51.03 KiB +65 B (+0.12%) 50.90 KiB 152.80 KiB 45.29 KiB ▆█████▄▁▁▁▁▇
vue-start.minimal 65.64 KiB +83 B (+0.12%) 65.52 KiB 189.35 KiB 58.43 KiB ▁█████▆▅▅▅▅█
vue-start.full 69.47 KiB +96 B (+0.14%) 69.34 KiB 201.65 KiB 61.63 KiB ▁▇▇▇▇▇▆▄▄▄▄█

Current gzip tracks all emitted client JS chunks. Initial gzip tracks only the entry/import graph. Trend sparkline is historical current gzip ending with this PR measurement; lower is better.

@pkg-pr-new

pkg-pr-new Bot commented Aug 16, 2026

Copy link
Copy Markdown
More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/@tanstack/arktype-adapter@8092

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/@tanstack/eslint-plugin-router@8092

@tanstack/eslint-plugin-start

npm i https://pkg.pr.new/@tanstack/eslint-plugin-start@8092

@tanstack/history

npm i https://pkg.pr.new/@tanstack/history@8092

@tanstack/nitro-v2-vite-plugin

npm i https://pkg.pr.new/@tanstack/nitro-v2-vite-plugin@8092

@tanstack/react-router

npm i https://pkg.pr.new/@tanstack/react-router@8092

@tanstack/react-router-devtools

npm i https://pkg.pr.new/@tanstack/react-router-devtools@8092

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/@tanstack/react-router-ssr-query@8092

@tanstack/react-start

npm i https://pkg.pr.new/@tanstack/react-start@8092

@tanstack/react-start-client

npm i https://pkg.pr.new/@tanstack/react-start-client@8092

@tanstack/react-start-rsc

npm i https://pkg.pr.new/@tanstack/react-start-rsc@8092

@tanstack/react-start-server

npm i https://pkg.pr.new/@tanstack/react-start-server@8092

@tanstack/router-cli

npm i https://pkg.pr.new/@tanstack/router-cli@8092

@tanstack/router-core

npm i https://pkg.pr.new/@tanstack/router-core@8092

@tanstack/router-devtools

npm i https://pkg.pr.new/@tanstack/router-devtools@8092

@tanstack/router-devtools-core

npm i https://pkg.pr.new/@tanstack/router-devtools-core@8092

@tanstack/router-generator

npm i https://pkg.pr.new/@tanstack/router-generator@8092

@tanstack/router-plugin

npm i https://pkg.pr.new/@tanstack/router-plugin@8092

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/@tanstack/router-ssr-query-core@8092

@tanstack/router-utils

npm i https://pkg.pr.new/@tanstack/router-utils@8092

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/@tanstack/router-vite-plugin@8092

@tanstack/solid-router

npm i https://pkg.pr.new/@tanstack/solid-router@8092

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/@tanstack/solid-router-devtools@8092

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/@tanstack/solid-router-ssr-query@8092

@tanstack/solid-start

npm i https://pkg.pr.new/@tanstack/solid-start@8092

@tanstack/solid-start-client

npm i https://pkg.pr.new/@tanstack/solid-start-client@8092

@tanstack/solid-start-server

npm i https://pkg.pr.new/@tanstack/solid-start-server@8092

@tanstack/start-client-core

npm i https://pkg.pr.new/@tanstack/start-client-core@8092

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/@tanstack/start-fn-stubs@8092

@tanstack/start-plugin-core

npm i https://pkg.pr.new/@tanstack/start-plugin-core@8092

@tanstack/start-server-core

npm i https://pkg.pr.new/@tanstack/start-server-core@8092

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/@tanstack/start-static-server-functions@8092

@tanstack/start-storage-context

npm i https://pkg.pr.new/@tanstack/start-storage-context@8092

@tanstack/valibot-adapter

npm i https://pkg.pr.new/@tanstack/valibot-adapter@8092

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/@tanstack/virtual-file-routes@8092

@tanstack/vue-router

npm i https://pkg.pr.new/@tanstack/vue-router@8092

@tanstack/vue-router-devtools

npm i https://pkg.pr.new/@tanstack/vue-router-devtools@8092

@tanstack/vue-router-ssr-query

npm i https://pkg.pr.new/@tanstack/vue-router-ssr-query@8092

@tanstack/vue-start

npm i https://pkg.pr.new/@tanstack/vue-start@8092

@tanstack/vue-start-client

npm i https://pkg.pr.new/@tanstack/vue-start-client@8092

@tanstack/vue-start-server

npm i https://pkg.pr.new/@tanstack/vue-start-server@8092

@tanstack/zod-adapter

npm i https://pkg.pr.new/@tanstack/zod-adapter@8092

commit: afc5b7c

@codspeed-hq

codspeed-hq Bot commented Aug 16, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 2.34%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 16 improved benchmarks
❌ 7 regressed benchmarks
✅ 157 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Memory mem server error-paths redirect (solid) 391.8 KB 1,058.1 KB -62.97%
Memory mem server peak-large-page (react) 1.2 MB 2.2 MB -47.12%
Memory mem server aborted-requests (vue) 983.8 KB 1,148.1 KB -14.31%
Memory mem server error-paths not-found (vue) 485.3 KB 551.8 KB -12.04%
Simulation client-nested-params navigation loop (react) 211.4 ms 226.5 ms -6.68%
Memory mem client interrupted-navigations (vue) 461 KB 480.6 KB -4.08%
Memory mem server request-churn (solid) 692.8 KB 721.2 KB -3.95%
Memory mem server error-paths unmatched (react) 789.7 KB 431.3 KB +83.12%
Memory mem server error-paths redirect (vue) 467.9 KB 396.2 KB +18.1%
Memory mem server error-paths not-found (react) 457.9 KB 419.6 KB +9.14%
Memory mem server error-paths not-found (solid) 623.9 KB 576.4 KB +8.24%
Simulation client-route-tree-scale navigation loop (react) 161.5 ms 150.2 ms +7.52%
Memory mem server server-fn-churn (vue) 373.4 KB 347.3 KB +7.51%
Simulation ssr global-mw document (vue) 970.4 ms 905.3 ms +7.19%
Memory mem client preload-churn (solid) 324.5 KB 305 KB +6.37%
Simulation client-control-flow navigation loop (vue) 125.2 ms 118.9 ms +5.3%
Simulation client-history navigation loop (react) 128.1 ms 123.1 ms +4.08%
Simulation client-history navigation loop (solid) 153.5 ms 147.5 ms +4.02%
Memory mem server error-paths redirect (react) 314 KB 302.3 KB +3.88%
Memory mem client navigation-churn (solid) 705.5 KB 679.3 KB +3.86%
... ... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing opencode/remove-all-rollback-v5 (afc5b7c) with opencode/retained-pending-architecture-v5 (425bab3)

Open in CodSpeed

@nx-cloud nx-cloud Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.

Nx Cloud is proposing a fix for your failed CI:

We updated the HMR e2e test to align with the intentional removal of navigation rollback in router-core. The assertion expecting the crumb to revert to 'Child' after a failed onStay hook has been corrected to 'Child Failed', since one-way navigation now commits the new loader state regardless of lifecycle hook errors. This brings the test in sync with the PR's stated goal of replacing rollback checkpoints with successor-owned navigation.

Tip

We verified this fix by re-running tanstack-react-start-e2e-hmr:test:e2e--rsbuild-ssr.

diff --git a/e2e/react-start/hmr/tests/app.spec.ts b/e2e/react-start/hmr/tests/app.spec.ts
index 69ce1d20..32a98ceb 100644
--- a/e2e/react-start/hmr/tests/app.spec.ts
+++ b/e2e/react-start/hmr/tests/app.spec.ts
@@ -684,7 +684,7 @@ test.describe('react-start hmr', () => {
     await expect(page.getByTestId('child')).toHaveText('child')
   })
 
-  test('rolls back a failed route refresh and accepts the next HMR update', async ({
+  test('accepts the next HMR update after a failed route refresh', async ({
     page,
   }) => {
     await page.goto('/child')
@@ -712,7 +712,7 @@ test.describe('react-start hmr', () => {
       },
     )
 
-    await expect(page.getByTestId('crumb-/child')).toHaveText('Child')
+    await expect(page.getByTestId('crumb-/child')).toHaveText('Child Failed')
     await expect(page.getByTestId('root-message')).toHaveValue(
       'preserved through failure',
     )

Apply fix via Nx Cloud  Reject fix via Nx Cloud


Or Apply changes locally with:

npx nx-cloud apply-locally W28Y-FjUD

Apply fix locally with your editor ↗   View interactive diff ↗



🎓 Learn more about Self-Healing CI on nx.dev

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.

1 participant