Skip to content
Source
Sign inSign up
TanStack/router

fix(router-core): preserve replacement promises on loader abort #7814

ClosedLadyBluenotes(GitHub profile, opens in a new tab)wants to merge 4 commits intomain fromfix/abort-error-loader-raceopened

Summary by CodeRabbit

  • Bug Fixes
    • Fixed rapid search/filter navigations to keep the latest loaded data displayed.
    • Prevented aborted loader executions from interfering with newer in-flight loads for the same route match.
    • Improved concurrent loading behavior during background revalidation, including correct suppression of error UI when a newer load supersedes a failing/aborted one.
  • Tests
    • Added a regression test covering aborting a reused parent match without clearing the replacement load promise.
  • Release
    • Patch release for router-core.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: react-router

    2. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: router-core

    3. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Review Change Stack

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration

      Configuration used: defaults

      Review profile: CHILL

      Plan: Pro

      Run ID: 9d8e58ab-8309-4fde-ba8a-9a3d241b10f5

      📥 Commits

      Reviewing files that changed from the base of the PR and between 10d8fc043ba534050fc755922e634ffb23250802 and ebca5c7d15293469881f8fe4bd3ef1c5dbce4144.

      📒 Files selected for processing (1)
      • packages/react-router/tests/loaders.test.tsx
      🚧 Files skipped from review as they are similar to previous changes (1)
      • packages/react-router/tests/loaders.test.tsx

      📝 Walkthrough

      Walkthrough

      Loader matching now tracks controlled promises per route match, prevents stale aborted loads from clearing replacement promises, and coordinates loader finalization. A regression test covers rapid search updates with reused parent matches.

      Changes

      Loader promise lifecycle

      Layer / File(s)Summary
      Per-match promise tracking
      packages/router-core/src/load-matches.ts
      Adds per-index controlled promise storage and records replacement promises during beforeLoad and load initialization.
      Load finalization and regression coverage
      packages/router-core/src/load-matches.ts, packages/react-router/tests/loaders.test.tsx, .changeset/eight-feet-lose.md
      Uses identity checks when resolving and clearing promises, updates abort handling, tests rapid search updates, and records a patch release.

      Estimated code review effort: 4 (Complex) | ~45 minutes

      Possibly related issues

      • TanStack/router#7791 — Related to controlled loaderPromise and loadPromise lifecycle handling in loadRouteMatch; this PR addresses stale-abort cleanup rather than synchronous fast paths.

      Suggested reviewers: sheraff

      🚥 Pre-merge checks | ✅ 4 | ❌ 1

      ❌ Failed checks (1 warning)

      Check nameStatusExplanationResolution
      Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
      ✅ Passed checks (4 passed)
      Check nameStatusExplanation
      Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
      Title check✅ PassedThe title accurately captures the main fix: aborted loaders no longer clear newer replacement promises in router-core.
      Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
      ✨ Finishing Touches
      📝 Generate docstrings
      • Create stacked PR
      • Commit on current branch
      🧪 Generate unit tests (beta)
      • Create PR with unit tests
      • Commit unit tests in branch `fix/abort-error-loader-race`

      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.
    4. nx-cloud[bot](GitHub profile, opens in a new tab)commented

      View your CI Pipeline Execution ↗ for commit ebca5c7d15293469881f8fe4bd3ef1c5dbce4144

      CommandStatusDurationResult
      nx affected --targets=test:eslint,test:unit,tes...❌ Failed5m 22sView ↗
      nx run-many --target=build --exclude=examples/*...✅ Succeeded25sView ↗

      ☁️ Nx Cloud last updated this comment at 2026-07-14 04:18:25 UTC

    5. github-actions[bot](GitHub profile, opens in a new tab)commented

      🚀 Changeset Version Preview

      1 package(s) bumped directly, 22 bumped as dependents.

      🟩 Patch bumps

      PackageVersionReason
      @tanstack/router-core1.171.15 → 1.171.16Changeset
      @tanstack/react-router1.170.18 → 1.170.19Dependent
      @tanstack/react-start1.168.28 → 1.168.29Dependent
      @tanstack/react-start-client1.168.16 → 1.168.17Dependent
      @tanstack/react-start-rsc0.1.27 → 0.1.28Dependent
      @tanstack/react-start-server1.167.22 → 1.167.23Dependent
      @tanstack/router-cli1.167.19 → 1.167.20Dependent
      @tanstack/router-generator1.167.19 → 1.167.20Dependent
      @tanstack/router-plugin1.168.20 → 1.168.21Dependent
      @tanstack/router-vite-plugin1.167.20 → 1.167.21Dependent
      @tanstack/solid-router1.170.18 → 1.170.19Dependent
      @tanstack/solid-start1.168.28 → 1.168.29Dependent
      @tanstack/solid-start-client1.168.16 → 1.168.17Dependent
      @tanstack/solid-start-server1.167.22 → 1.167.23Dependent
      @tanstack/start-client-core1.170.14 → 1.170.15Dependent
      @tanstack/start-plugin-core1.171.20 → 1.171.21Dependent
      @tanstack/start-server-core1.169.17 → 1.169.18Dependent
      @tanstack/start-static-server-functions1.167.19 → 1.167.20Dependent
      @tanstack/start-storage-context1.167.17 → 1.167.18Dependent
      @tanstack/vue-router1.170.17 → 1.170.18Dependent
      @tanstack/vue-start1.168.27 → 1.168.28Dependent
      @tanstack/vue-start-client1.167.19 → 1.167.20Dependent
      @tanstack/vue-start-server1.167.22 → 1.167.23Dependent
    6. github-actions[bot](GitHub profile, opens in a new tab)commented

      Bundle Size Benchmarks

      • Commit: 8b92316c29b2
      • Measured at: 2026-07-14T04:14:09.762Z
      • Baseline source: history:11a6a0d8ba4d
      • Dashboard: bundle-size history
      ScenarioCurrent (gzip)Delta vs baselineInitial gzipRawBrotliTrend
      react-router.minimal87.39 KiB+40 B (+0.04%)87.25 KiB273.70 KiB75.96 KiB▁▁▆▆▆▆▆▆▃▃▃█
      react-router.full91.11 KiB+49 B (+0.05%)90.97 KiB285.60 KiB79.11 KiB▁▁▇▇▇▇▇▇▁▁▁█
      solid-router.minimal35.58 KiB+56 B (+0.15%)35.46 KiB105.89 KiB32.07 KiB▁▁▆▆▆▆▆▆▁▁▁█
      solid-router.full40.63 KiB+45 B (+0.11%)40.50 KiB121.11 KiB36.56 KiB▁▁▆▆▆▆▆▆▁▁▁█
      vue-router.minimal53.05 KiB+55 B (+0.10%)52.92 KiB149.93 KiB47.65 KiB▂▂██████▁▁▁▇
      vue-router.full58.99 KiB+50 B (+0.08%)58.86 KiB168.69 KiB52.80 KiB▅▅██████▁▁▁▅
      react-start.minimal102.04 KiB+54 B (+0.05%)101.90 KiB322.13 KiB88.22 KiB▁▄▇▇▇▇▇▇▄▄▄█
      react-start.deferred-hydration102.78 KiB+57 B (+0.05%)101.92 KiB323.50 KiB89.04 KiB▁▃▇▇▇▇▇▇▃▃▃█
      react-start.full105.42 KiB+54 B (+0.05%)105.28 KiB332.06 KiB91.12 KiB▁▄██████▁▁▁▆
      react-start.rsbuild.minimal99.75 KiB+78 B (+0.08%)99.58 KiB316.56 KiB85.83 KiB▁▄▇▇▇▇▇▇▃▃▃█
      react-start.rsbuild.minimal-iife100.16 KiB+79 B (+0.08%)99.99 KiB317.50 KiB86.29 KiB▁▄▇▇▇▇▇▇▃▃▃█
      react-start.rsbuild.full102.99 KiB+96 B (+0.09%)102.82 KiB326.62 KiB88.58 KiB▁▃▆▆▆▆▆▆▂▂▂█
      solid-start.minimal49.65 KiB+43 B (+0.08%)49.52 KiB152.06 KiB43.90 KiB▃▅██████▁▁▁▄
      solid-start.deferred-hydration52.91 KiB+42 B (+0.08%)49.58 KiB160.10 KiB46.85 KiB▃▅██████▁▁▁▄
      solid-start.full55.47 KiB+53 B (+0.09%)55.34 KiB169.11 KiB48.91 KiB▃▆██████▁▁▁▅
      vue-start.minimal71.08 KiB+54 B (+0.07%)70.95 KiB207.18 KiB62.95 KiB▄▇██████▁▁▁▅
      vue-start.full75.08 KiB+50 B (+0.07%)74.95 KiB219.82 KiB66.45 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.

    7. pkg-pr-new[bot](GitHub profile, opens in a new tab)commented
      More templates

      @tanstack/arktype-adapter

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

      @tanstack/eslint-plugin-router

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

      @tanstack/eslint-plugin-start

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

      @tanstack/history

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

      @tanstack/nitro-v2-vite-plugin

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

      @tanstack/react-router

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

      @tanstack/react-router-devtools

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

      @tanstack/react-router-ssr-query

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

      @tanstack/react-start

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

      @tanstack/react-start-client

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

      @tanstack/react-start-rsc

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

      @tanstack/react-start-server

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

      @tanstack/router-cli

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

      @tanstack/router-core

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

      @tanstack/router-devtools

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

      @tanstack/router-devtools-core

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

      @tanstack/router-generator

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

      @tanstack/router-plugin

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

      @tanstack/router-ssr-query-core

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

      @tanstack/router-utils

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

      @tanstack/router-vite-plugin

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

      @tanstack/solid-router

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

      @tanstack/solid-router-devtools

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

      @tanstack/solid-router-ssr-query

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

      @tanstack/solid-start

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

      @tanstack/solid-start-client

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

      @tanstack/solid-start-server

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

      @tanstack/start-client-core

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

      @tanstack/start-fn-stubs

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

      @tanstack/start-plugin-core

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

      @tanstack/start-server-core

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

      @tanstack/start-static-server-functions

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

      @tanstack/start-storage-context

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

      @tanstack/valibot-adapter

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

      @tanstack/virtual-file-routes

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

      @tanstack/vue-router

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

      @tanstack/vue-router-devtools

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

      @tanstack/vue-router-ssr-query

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

      @tanstack/vue-start

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

      @tanstack/vue-start-client

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

      @tanstack/vue-start-server

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

      @tanstack/zod-adapter

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

      commit: ebca5c7

    8. 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 has identified a possible root cause for your failed CI:

      We determined this failure is unrelated to the PR's changes. The tanstack-solid-start-e2e-basic e2e test failed because port 44231 was already in use in the CI environment (EADDRINUSE), preventing the test server from starting. Our analysis confirms the PR only touched @tanstack/react-router and @tanstack/router-core, so this is an environment-level issue that requires a re-run.

      No code changes were suggested for this issue.

      Trigger a rerun:

      Rerun CI

      Nx Cloud View detailed reasoning on Nx Cloud ↗


      🎓 Learn more about Self-Healing CI on [nx.dev](https://nx.dev/docs/features/ci-features/self-healing-ci?utm_source=pull-request&utm_medium=comment)
    9. Actionable comments posted: 1

      Caution

      Some comments are outside the diff and can’t be posted inline due to platform limitations.

      ⚠️ Outside diff range comments (1)
      packages/router-core/src/load-matches.ts (1)

      777-784: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

      Guard the loaderPromise reset in the outer catch packages/router-core/src/load-matches.ts:777-784 still clears match._nonReactive.loaderPromise unconditionally; that can wipe out a newer in-flight load’s promise.

      🤖 Prompt for AI Agents
      Verify each finding against current code. Fix only still-valid issues, skip the
      rest with a brief reason, keep changes minimal, and validate.
      
      In `@packages/router-core/src/load-matches.ts` around lines 777 - 784, Update the
      outer catch around handleRedirectAndNotFound to reset
      match._nonReactive.loaderPromise only when it still refers to the failed load’s
      promise, preserving any newer in-flight loader promise. Use the existing loader
      promise captured by the surrounding load flow and retain the missing-match
      guard.
      🤖 Prompt for all review comments with AI agents
      Verify each finding against current code. Fix only still-valid issues, skip the
      rest with a brief reason, keep changes minimal, and validate.
      
      Inline comments:
      In `@packages/react-router/tests/loaders.test.tsx`:
      - Around line 1013-1023: Update the test around the filter-change loop to verify
      that the root loader actually reruns for the reused parent match, rather than
      only asserting its in-flight request was aborted. Assert the root loader mock’s
      call count or configure the root route to depend on the navigation, while
      preserving the existing abort and error-component assertions.
      
      ---
      
      Outside diff comments:
      In `@packages/router-core/src/load-matches.ts`:
      - Around line 777-784: Update the outer catch around handleRedirectAndNotFound
      to reset match._nonReactive.loaderPromise only when it still refers to the
      failed load’s promise, preserving any newer in-flight loader promise. Use the
      existing loader promise captured by the surrounding load flow and retain the
      missing-match guard.
      🪄 Autofix (Beta)

      Fix all unresolved CodeRabbit comments on this PR:

      • Push a commit to this branch (recommended)
      • Create a new PR with the fixes

      ℹ️ Review info
      ⚙️ Run configuration

      Configuration used: defaults

      Review profile: CHILL

      Plan: Pro

      Run ID: 163b889e-c1dd-4e3c-8e15-7c2e75806f38

      📥 Commits

      Reviewing files that changed from the base of the PR and between 11a6a0d8ba4db37714a6b1d723910bdf7dbe38af and 23cc7b8f1df43013b50936021ee53217b41f8b26.

      📒 Files selected for processing (2)
      • packages/react-router/tests/loaders.test.tsx
      • packages/router-core/src/load-matches.ts
    10. codspeed[bot](GitHub profile, opens in a new tab)commented

      Merging this PR will degrade performance by 24.12%

      :warning: 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

      ⚡ 5 improved benchmarks ❌ 7 regressed benchmarks ✅ 168 untouched benchmarks

      Warning

      Please fix the performance issues or acknowledge them on CodSpeed.

      Performance Changes

      ModeBenchmarkBASEHEADEfficiency
      ❌Memorymem server server-fn-churn (vue)274.8 KB4,248.2 KB-93.53%
      ❌Memorymem server error-paths redirect (vue)304.3 KB778.3 KB-60.91%
      ❌Memorymem server error-paths redirect (solid)441 KB832.7 KB-47.03%
      ❌Memorymem server error-paths unmatched (react)641.2 KB770.4 KB-16.77%
      ❌Simulationclient-preload interaction loop (react)57.3 ms60.6 ms-5.41%
      ❌Simulationclient-route-tree-scale navigation loop (react)74.2 ms77.2 ms-3.9%
      ❌Memorymem server error-paths not-found (react)266.8 KB276.3 KB-3.44%
      ⚡Memorymem server peak-large-page (react)2,080.9 KB953.8 KB×2.2
      ⚡Memorymem server serialization-payload (react)5.3 MB3.4 MB+53.32%
      ⚡Simulationssr selective (react)64.3 ms61.9 ms+3.78%
      ⚡Simulationssr selective (solid)74.7 ms72 ms+3.7%
      ⚡Simulationssr streaming deferred (react)73.1 ms70.7 ms+3.42%

      Tip

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


      Comparing fix/abort-error-loader-race (ebca5c7) with main (11a6a0d) Open in CodSpeed

Sign in to join this conversation.