TanStack / router

🤖 Fully typesafe Router for React (and friends) w/ built-in caching, 1st class search-param APIs, client-side cache integration and isomorphic rendering.
https://tanstack.com/router
MIT License
7.27k stars 495 forks source link

fix(react-router): do not over-eagerly garbage collect #1619

Closed SeanCassiere closed 2 weeks ago

SeanCassiere commented 2 weeks ago

When the user sets a defaultGcTime on the router or a gcTime on a route to the value of 0, the current eager garbage collection we've got going on ends up setting the route-context to undefined.

This normally wouldn't matter on direct navigation, however, when redirects come into play this results in the route trying to execute its options (beforeLoad, loader, component, etc) without its processed route context being available. The current setup looks to perform garbage collection both before and after a this.loadMatches has been called in router.load.

This change makes it so that garbage collection is done after the this.loadMatches call has resolved.

This is part of the fix for #1531.

nx-cloud[bot] commented 2 weeks ago

☁️ Nx Cloud Report

CI is running/has finished running commands for commit e70a76446fbaa8ceba2a45ad1bda94d97714e1e5. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 2 targets - [`nx affected --targets=test:format,test:eslint,test:unit,test:build,build --parallel=3`](https://cloud.nx.app/runs/wfBsdybu30?utm_source=pull-request&utm_medium=comment) - [`nx affected --target=test:types --exclude=examples/**`](https://cloud.nx.app/runs/s7Ly5jl2qy?utm_source=pull-request&utm_medium=comment)

Sent with 💌 from NxCloud.