fix(router-core): handle skipped view transition promises #8802
main fromrefs/pull/8802/head·opened Fixes #8776
🎯 Changes#
startViewTransition only returned updateCallbackDone, so when the browser skips a transition (two navigations within ~1 frame) the rejected ready / finished promises were unhandled (AbortError: Transition was skipped).
const transition = document.startViewTransition(params)
transition.ready?.catch(() => {})
transition.finished?.catch(() => {})
return transition.updateCallbackDone
updateCallbackDone is returned unchanged, so update errors still propagate.
Added packages/router-core/tests/view-transition.test.ts (navigation with rejecting ready/finished, missing optional promises, updateCallbackDone identity + rejection). The first test fails without the fix.
✅ Checklist#
- I have followed the steps in the Contributing guide.
- I have tested code changes locally with the relevant test commands, or tests do not apply to this pull request.
- I fully understand the code in this pull request, including any code generated with AI assistance.
Ran locally: test:unit, test:types, test:eslint, test:build for router-core, react-router, solid-router, vue-router — all pass. The viewTransition e2e tests couldn't launch Chromium in my sandbox, so they were not run.
🚀 Release Impact#
- This change affects published code, and I have generated a changeset.
- This change is docs/CI/dev-only (no release).
AI disclosure: the change and test were drafted with an AI coding agent (Codex) and reviewed before submitting.
Summary by CodeRabbit#
- Bug Fixes
- Navigation now completes when a view transition is skipped, even if its readiness or completion promises reject.
- Navigation also succeeds when optional transition promises are unavailable.
- Rejections from the transition update remain observable to callers.
- 1
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Source mode: Auto
- Repository: TanStack/router
- Branch: main
- File: .coderabbit.yaml
- Commit: 6b9fe6d
- Layers: Repository YAML
- Review profile: CHILL
- Plan: Advanced
- Run ID:
8242bc5b-765a-4810-9df4-090d9ca51410
📥 Commits
-
Reviewing files that changed from the base of the PR and between 6b9fe6d29552270836c511bc9b343d73541f4424 and e2af57bb0c3db883832a56a9bb5eafe733fbf86e.
📒 Files selected for processing: 3
-
.changeset/cold-ravens-raise.mdpackages/router-core/src/router.tspackages/router-core/tests/view-transition.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
-
📝 Walkthrough
-
The router now attaches rejection handlers to a view transition’s optional
readyandfinishedpromises. It continues to returnupdateCallbackDone, with tests covering rejected and absent optional promises and observable rejection of the returned promise.Changes: View transition promise handling
Layer / File(s) Summary Handle transition promises
packages/router-core/src/router.ts,packages/router-core/tests/view-transition.test.ts,.changeset/cold-ravens-raise.mdThe router handles rejections from optional readyandfinishedpromises and returnsupdateCallbackDone. Tests cover navigation when those promises reject or are absent, and verify that rejection ofupdateCallbackDoneremains observable. The changeset records the patch.Priority: ➖ Normal
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Suggested reviewers:
sheraff
Merge Risk: ⚪ Minimal · up to
e2af5-
No actionable issue remains; the change is ready to merge after normal checks.
Pre-merge checks:
4 · 1-
Failed checks: 1 warningCheck name Status Explanation Resolution Docstring Coverage Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold. Passed checks: 4 passed-
Check name Status Explanation Title check The title clearly identifies the router-core fix for skipped view transition promises and matches the main change. Description check The description explains the issue, implementation, tests, release impact, incomplete e2e coverage, and AI authorship. It follows the required template and includes a changeset. Linked Issues check Issue #8776requires handlers for rejectedreadyandfinishedpromises from started view transitions.packages/router-core/src/router.tsnow attaches no-op handlers to both optional promises and…Out of Scope Changes check The changes stay within issue #8776. The source change handles skipped transition rejections. The tests verify this behavior and preserve update error behavior. The changeset documents the published f…Full details: Linked Issues check
-
Explanation
Issue
#8776requires handlers for rejectedreadyandfinishedpromises from started view transitions.packages/router-core/src/router.tsnow attaches no-op handlers to both optional promises and returnstransition.updateCallbackDoneunchanged. The added tests cover rejected promises, missing optional promises, and update-promise identity and rejection.
Full details: Out of Scope Changes check
-
Explanation
The changes stay within issue
#8776. The source change handles skipped transition rejections. The tests verify this behavior and preserve update error behavior. The changeset documents the published fix.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (1 skipped: 1 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
✨ Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment `@coderabbitai help` to get the list of available commands.-
Gentle ping in case this slipped through: the PR is rebased-ready and checks are green. Happy to adjust the approach or add more test coverage if a maintainer would prefer a different fix. Thanks for your time!
unjica(GitHub profile, opens in a new tab) linked this to fix #8776
Sign in to join this conversation.
🦋 Changeset detected#
Latest commit: e2af57bb0c3db883832a56a9bb5eafe733fbf86e
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 23 packages
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR