Redirect from an effect during a pending navigation livelocks since router-core 1.171.16 (state.location alternates, nothing commits)
メンテナーはふだん 1 日以内に返信
@Sheraff がすでに取り組んでいます。
2026年10月18日 から。
評価
この issue はまだ評価されていません。
説明
Which project does this relate to?
Router (in a Start app)
Describe the bug
Seen in a TanStack Start app; a standalone minimal repro is still pending (details below).
Starting with @tanstack/router-core 1.171.16 (#7805, the lane-based scheduler), a redirect issued from a component effect while another navigation is still pending can livelock. state.location keeps alternating between the two destinations, neither navigation commits, and the page stops responding.
The pattern (a root-level "gate" that sends the user to another route):
function Root() {
const path = useRouterState({ select: (s) => s.location.pathname })
const navigate = useNavigate()
useEffect(() => {
if (path !== '/') return
navigate({ to: '/step', replace: true })
}, [path, navigate])
return <Outlet />
}
The sequence we observe:
- On
/login, a successful sign-in callsnavigate({ to: '/' }). That navigation is still pending (status: 'pending',resolvedLocation=/login). - The root re-renders with
location.pathname === '/', and the effect callsnavigate({ to: '/step', replace: true }). - From here
state.location.pathnamealternates/step,/,/step,/… on successive renders.resolvedLocationstays/login,statusstays'pending', and the browser URL never moves. The switch back to/happens before the effect's secondnavigatecall. It looks as though the superseded/navigation re-publishes its location over the newer pending one. - Because the effect is keyed on
location.pathname, it sees/again and re-issues the navigation. Each re-issue settles the pending transition as superseded (Transitioner:settleOwner(acknowledgement, false)), and the cycle repeats.
On a production build this showed up as an intermittent hang. On the Vite dev server it happens every time. Measured there, the root component renders about 6,500 times a second and navigate is called about 1,700 times a second. The renderer pins a core, and CDP calls (Runtime.evaluate, Performance.enable) stop answering.
Captured router state per render (loc = state.location.pathname):
loc=/login resolved=/login status=idle
loc=/ resolved=/login status=pending <- navigation after sign-in, still pending
loc=/step resolved=/login status=pending <- effect: navigate({ to: '/step', replace: true })
loc=/ resolved=/login status=pending <- reverted before any second navigate call
loc=/step resolved=/login status=pending
loc=/ resolved=/login status=pending
… (indefinitely)
Bisect
We bisected over @tanstack/react-start releases (each pins its router packages). Same app code throughout:
| react-start | react-router / router-core | result |
|---|---|---|
| 1.168.35 | 1.170.18 / 1.171.15 | redirect commits |
| 1.168.36 | 1.170.19 / 1.171.16 | livelock |
| 1.168.42 | 1.170.25 / 1.171.21 (react-store still 0.9.3) |
livelock |
| 1.168.60 | 1.170.41 / 1.171.34 | livelock |
| 1.168.61 | 1.170.42 / 1.171.35 | livelock |
| react-router 1.170.45 / router-core 1.171.38 (forced) | livelock |
router-core 1.171.16 is the release that contains #7805.
Standalone repro attempts (none reproduce yet)
All on a bare Vite + React app with @tanstack/react-router 1.170.41, code-based routes, and the effect above, with /step having a 50 ms loader:
- Start at
/. The redirect commits (4 renders). - Start at
/login; a button navigates to/, whose loader takes 50 ms, then 2 s, so the effect fires while/is pending. The redirect commits. - As (2), plus an unrelated
setStatein the root every 20 ms. The redirect commits (308 renders).
Ingredients present in the Start app and absent from these attempts:
- the Start client entry, with hydration of a server-rendered first document;
- a
beforeLoadon/that canthrow redirect(). Disabling it did not stop the loop in the app, so it is probably not required; - the redirect target being a lazily loaded file route.
We'll update this issue if we get a standalone repro.
Expected behavior
While navigations overlap, state.location moves toward the latest requested navigation and does not revert to a superseded one. The latest navigation commits.
Workaround
Decide the redirect on the committed location (resolvedLocation?.pathname ?? location.pathname), and issue at most one navigation per (committed route, target). With that, our previously hanging cases pass every time.
Platform
@tanstack/react-start1.168.60,@tanstack/react-router1.170.41,@tanstack/router-core1.171.34- React 19, Vite 7, Chromium (Playwright), macOS and Linux CI
- 主要言語
- TypeScript
- スター
- 15.3k
- フォーク
- 1.9k
- 平均マージ
- 1日 5時間
- マージ済み PR(30日)
- 46
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
TanStack/router のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
Masked navigation drops the first character of the hash each time (__tempLocation hash missing '#')対応中かも @hassanabrar202 が 8 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
router-generator: lazy-load Prettier (costs ~300–450ms per build even when formatting is off)対応中かも @Sheraff が 27 日前に担当しました。 オープンpackage: router-generator performance
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
router-generator: sibling `physical()` subtrees in a virtual route config generate duplicate identifiers対応中かも @Sheraff が 27 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
docs(router): clarify static title fallback in SPA mode対応中かも @Rohan-Dedhia が 17 日前に担当しました。 オープン
難易度 1/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
TanStack/router の issue をすべて見る
似ている issue
-
[BUG]: Shared links drop the configured basePath on GitHub Pages対応中かも @anshulchikhale30-p が今日担当しました。 オープンbug
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
StabilityNexus/IdentityTokens-EVM-Frontend#182 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Add: GTrekkerオープンcheck:passed streams:add
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
Koenkk/zigbee-herdsman-converters#13900 ·
メンテナーはふだん 1 日以内に返信
-
area: ui Bug Payload OSS
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
payloadcms/payload#19839 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
jeanibarz/knowledge-base-mcp-server#1291 ·
メンテナーはふだん 1 日以内に返信