router.startViewTransition leaves the ready/finished promises unhandled, so a skipped transition throws an unhandled AbortError
维护者通常 1 天内回复
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 74/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript
- 领域
- frontend
调研方向
从 router-core/src/router.ts 中的 router.startViewTransition 开始,这里会调用 document.startViewTransition(fn) 并使用 updateCallbackDone。用 issue 中连续两次导航复现未处理的拒绝,然后检查 transition 的 ready 和 finished promise 是如何处理的。被跳过的 transition 不再导致未处理的拒绝时,即为完成。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
With defaultViewTransition: true, router.startViewTransition (router-core/src/router.ts) calls
document.startViewTransition(fn).updateCallbackDone and drops the ViewTransition object.
Its ready and finished promises get no handler.
updateCallbackDone settles when the DOM update is done, well before the animation ends. So any
navigation that starts while the previous cross-fade is still animating skips that transition,
the browser rejects its ready with AbortError: Transition was skipped. New ViewTransition started,
and nothing handles the rejection. await router.navigate() does not prevent it, because it
resolves on updateCallbackDone.
In an app this is console noise on quick consecutive navigations. In a test runner
(vitest browser mode) it fails the whole run: every test passes, then vitest reports
"Unhandled Rejection" and exits non-zero.
Reproduction
Vitest browser mode (chromium), no UI needed:
import { createMemoryHistory, createRootRoute, createRoute, createRouter } from '@tanstack/react-router'
import { test } from 'vitest'
test('two navigations in a row', async () => {
const root = createRootRoute()
const a = createRoute({ getParentRoute: () => root, path: '/a' })
const b = createRoute({ getParentRoute: () => root, path: '/b' })
const router = createRouter({
routeTree: root.addChildren([a, b]),
history: createMemoryHistory({ initialEntries: ['/a'] }),
defaultViewTransition: true,
})
await router.load()
await router.navigate({ to: '/b' })
await router.navigate({ to: '/a' })
})
Result: the test passes, then Unhandled Rejection: AbortError: Transition was skipped. New ViewTransition started and a failing exit code.
Expected behavior
A skipped transition is not an error for the app. The router should attach a no-op handler to
ready and finished of the transition it starts.
Verified
Wrapping document.startViewTransition so the returned object gets
t.ready.catch(() => {}) and t.finished.catch(() => {}) removes the error completely
(0 errors in the same repro).
Versions
@tanstack/react-router 1.170.45, @tanstack/router-core 1.171.38, Chromium (vitest browser mode)
- 主要语言
- TypeScript
- 星标
- 15.2k
- 派生
- 1.9k
- 平均合并
- 1 天 4 小时
- 30 天内合并 PR
- 63
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
TanStack/router 的其他 Issue
-
Router devtools crash when search params contain a BigInt (JSON.stringify in history tracking)可能已有人在做 @A-Raphie 于 9 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
docs: `createLink` has no API reference page; 3 how-to guides link to a missing `#createlink` anchor可能已有人在做 @A-Raphie 于 9 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
Inline scripts are duplicated after hydration when the CSP nonce is sent in a header可能已有人在做 @gabriel-le 于 30 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 90/100
维护者通常 1 天内回复
-
start-plugin-core: sitemap lastmod and pages.json lastBuilt are stamped with the build's wall clock (no SOURCE_DATE_EPOCH support)可能已有人在做 @treadnot 于 32 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
Empty .ts route file is scaffolded with JSX, breaking all route generation可能已有人在做 @nathan-logan 于 36 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
相似的 Issue
-
area:plugins area:security area:skills bug has repro
难度 2/5 1-3 小时 新手友好度 76/100
anthropics/claude-code#105911 ·
维护者通常 1 天内回复
-
openspec-apply-change skill: when blocked, may select a ready artifact unrelated to missingArtifacts未关闭
难度 2/5 1-3 小时 新手友好度 72/100
Fission-AI/OpenSpec#2165 ·
维护者通常 1 天内回复
-
🐞 bug 🧐 unconfirmed
难度 2/5 1-3 小时 新手友好度 66/100
Tencent/tdesign-vue-next#7032 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
gnosis/gnosis_vpn#661 ·
维护者通常 1 天内回复
-
content-freshness: staleOwnedContent doc comments still say 'complete receipt' (follow-up to #7912)未关闭triage:bug-verified
难度 1/5 1 小时以内 新手友好度 92/100
维护者通常 1 天内回复