Skip to content

Conversation

@jiji-hoon96
Copy link
Contributor

Fixes #4245

Problem

When a route refetch is in progress and the user navigates away then immediately returns, the cached stale data is lost, causing an empty page until the loader completes.

  • Expected behavior: Show stale data immediately while refetch continues in background
  • Actual behavior: Empty page until refetch completes

Root Cause

In beforeLoad(), the cached matches filter was too aggressive - it removed all cached matches that had the same ID as pending matches, even when those cached matches contained valid stale data from an ongoing refetch.

Solution

Modified the cache filtering logic to preserve successful cached matches that are currently fetching or have loader data available.

@nx-cloud
Copy link

nx-cloud bot commented Jun 26, 2025

View your CI Pipeline Execution ↗ for commit 76a3c59.

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

☁️ Nx Cloud last updated this comment at 2025-06-26 21:06:13 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jun 26, 2025

More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@4513

@tanstack/directive-functions-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/directive-functions-plugin@4513

@tanstack/eslint-plugin-router

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

@tanstack/history

npm i https://pkg.pr.new/TanStack/router/@tanstack/history@4513

@tanstack/react-router

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

@tanstack/react-router-devtools

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

@tanstack/react-router-with-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-with-query@4513

@tanstack/react-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@4513

@tanstack/react-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@4513

@tanstack/react-start-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-plugin@4513

@tanstack/react-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@4513

@tanstack/router-cli

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

@tanstack/router-core

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

@tanstack/router-devtools

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

@tanstack/router-devtools-core

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

@tanstack/router-generator

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

@tanstack/router-plugin

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

@tanstack/router-utils

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

@tanstack/router-vite-plugin

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

@tanstack/server-functions-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/server-functions-plugin@4513

@tanstack/solid-router

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

@tanstack/solid-router-devtools

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

@tanstack/solid-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@4513

@tanstack/solid-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@4513

@tanstack/solid-start-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-plugin@4513

@tanstack/solid-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@4513

@tanstack/start-client-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@4513

@tanstack/start-plugin-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@4513

@tanstack/start-server-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@4513

@tanstack/start-server-functions-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-functions-client@4513

@tanstack/start-server-functions-fetcher

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-functions-fetcher@4513

@tanstack/start-server-functions-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-functions-server@4513

@tanstack/valibot-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@4513

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@4513

@tanstack/zod-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@4513

commit: 76a3c59

@schiller-manuel
Copy link
Contributor

thanks for the fix!

@schiller-manuel schiller-manuel merged commit 40f456e into TanStack:main Jun 26, 2025
5 checks passed
schiller-manuel added a commit that referenced this pull request Jun 30, 2025
this reverts #4513 and implements a proper fix for #4245

fixes #4546
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.

Navigating while refetch is in progress results in cache not being used

2 participants