-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
fix(nuxt): sync internal route before calling page:finish hook
#33707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
|
WalkthroughRoute synchronization wiring was changed: the inline pre-hook registration Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20–30 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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 |
@nuxt/kit
@nuxt/nitro-server
nuxt
@nuxt/rspack-builder
@nuxt/schema
@nuxt/vite-builder
@nuxt/webpack-builder
commit: |
page:finish hook before any async operation to ensure correct order
CodSpeed Performance ReportMerging #33707 will not alter performanceComparing Summary
|
page:finish hook before any async operation to ensure correct orderpage:finish hook
page:finish hookpage:finish hook
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
test/nuxt/nuxt-layout.test.ts (2)
134-142: Consider addressing the TODO and "should be" comments.Whilst the reduced route changes and renders (from 3→2) reflect an improvement from the route synchronization fix, the inline comments indicate the behaviour is still not optimal. The secondary rerender and extra route change suggest there may be additional opportunities to refine the synchronization timing.
Should this TODO be tracked in a separate issue, or is it within scope for this PR to investigate why
routeChangesand renders are 2 instead of the ideal 1?
12-210: Consider adding a test specifically for thepage:finishhook behaviour.Whilst this test verifies that layouts receive correct route values during navigation, it doesn't directly test the bug described in issue #33704: that the
page:finishhook was receiving outdateduseRoute()values when registered with object syntax.Consider adding a test case that:
- Registers a
page:finishhook using both object and function syntax- Navigates between routes
- Verifies that both hook registrations receive the updated route path, not the previous one
This would provide explicit regression coverage for the reported issue and make the test suite more comprehensive.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
test/nuxt/nuxt-layout.test.ts(3 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: huang-julien
Repo: nuxt/nuxt PR: 29366
File: packages/nuxt/src/app/components/nuxt-root.vue:16-19
Timestamp: 2024-12-12T12:36:34.871Z
Learning: In `packages/nuxt/src/app/components/nuxt-root.vue`, when optimizing bundle size by conditionally importing components based on route metadata, prefer using inline conditional imports like:
```js
const IsolatedPage = route?.meta?.isolate ? defineAsyncComponent(() => import('#build/isolated-page.mjs')) : null
```
instead of wrapping the import in a computed property or importing the component unconditionally.
Learnt from: GalacticHypernova
Repo: nuxt/nuxt PR: 26468
File: packages/nuxt/src/components/plugins/loader.ts:24-24
Timestamp: 2024-11-05T15:22:54.759Z
Learning: In `packages/nuxt/src/components/plugins/loader.ts`, the references to `resolve` and `distDir` are legacy code from before Nuxt used the new unplugin VFS and will be removed.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: code
🔗 Linked issue
fix #33704
📚 Description