Skip to content

fix(data-loaders): do not crash on duplicated SSR navigations - #2831

Open
re-thc wants to merge 1 commit into
vuejs:mainfrom
re-thc:vr-fix-3
Open

re-thc wants to merge 1 commit into
vuejs:mainfrom
re-thc:vr-fix-3

Conversation

@re-thc

@re-thc re-thc commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

A duplicated navigation to a route with loader server: false crashes on SSR with TypeError instead of resolving the navigation failure.

This fixes the crash.

Summary by CodeRabbit

  • Bug Fixes
    • Repeated navigation to a route with a client-only data loader is now handled correctly, including when the navigation is identified as a duplicate.

@netlify

netlify Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for vue-router canceled.

Name Link
🔨 Latest commit 10e004c
🔍 Latest deploy log https://app.netlify.com/projects/vue-router/deploys/6ac7ce74d25c6d0008cc1bfc

@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: vuejs/router/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 60a51ea2-6bb2-4862-b2c4-12205bf9831e
📥 Commits

Reviewing files that changed from the base of the PR and between 42462bd and 10e004c.

📒 Files selected for processing (2)
  • packages/router/src/experimental/data-loaders/navigation-guard.spec.ts
  • packages/router/src/experimental/data-loaders/navigation-guard.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The duplicated-navigation cleanup now checks for a loader entry before resetting pending state. A server-side regression test verifies the initial navigation and repeated-navigation failure for a loader configured with server: false.

Changes

Navigation guard cleanup

Layer / File(s) Summary
Handle missing entries in duplicated-navigation cleanup
packages/router/src/experimental/data-loaders/navigation-guard.ts, packages/router/src/experimental/data-loaders/navigation-guard.spec.ts
The cleanup calls resetPending() only when a loader entry exists. The test verifies that the first push to /fetch succeeds and the second produces a duplicated-navigation failure.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 10e00

Repeated SSR navigation to a route with a server:false loader now avoids the missing-entry crash. The inspected path has no pending state to clean up, and no actionable merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: preventing crashes during duplicated SSR navigations in data loaders.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Oct 8, 2026

Copy link
Copy Markdown

Open in StackBlitz

pnpm add https://pkg.pr.new/vue-router@2831
npm i https://pkg.pr.new/vue-router@2831
yarn add https://pkg.pr.new/vue-router@2831.tgz

commit: 10e004c

@codecov

codecov Bot commented Oct 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.26%. Comparing base (42462bd) to head (10e004c).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2831   +/-   ##
=======================================
  Coverage   88.26%   88.26%           
=======================================
  Files          78       78           
  Lines        6305     6305           
  Branches     2048     2048           
=======================================
  Hits         5565     5565           
  Misses        651      651           
  Partials       89       89           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@posva posva left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if the fix is one char, I'm afraid it could hide other bugs in the future.

Do you have any realistic reproduction of this bug?


await router.push('/fetch')
expect(router.currentRoute.value.path).toBe('/fetch')
const failure = await router.push('/fetch')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But why would this happen during SSR? There is only one navigation on the server

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants