Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

router.startViewTransition leaves the ready/finished promises unhandled, so a skipped transition throws an unhandled AbortError

未关闭 适合新手
#8,776 3 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@unjica 已经在做这个了。

开始于 2026年10月23日。

  • #8802 来自 @unjica —— 未关闭

评估

难度
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

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

TanStack/router 的其他 Issue

查看 TanStack/router 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。