fix(Link): wait for onNuxtReady before observing visibility - #6922
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughLink prefetching now waits for Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to ULink prefetching now waits until Nuxt is ready, avoiding hydration-time request contention while retaining cleanup on unmount. The change is ready to merge. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Some tools did not complete. Review the errors below. 🔧 ESLint
src/runtime/components/Link.vueParsing error: Unexpected token ) 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 |
commit: |
🔗 Linked issue
Follow-up to #6921
❓ Type of change
📚 Description
Before Nuxt 4.5,
NuxtLinkobservedcustomlinks itself and only started the visibility observer insideonNuxtReady. #6921 rebuilt that observer inULinkbut scheduled it straight fromonMounted, soULinkstarted prefetching earlier than a plainNuxtLink.This matters for two reasons:
nuxt:payloadplugin registers itslink:prefetchlistener insideonNuxtReady, andprefetch()marks the link as prefetched before calling the hook. If a plugin ordered beforenuxt:payloadreturns a promise fromapp:suspense:resolve, an early visible link can fire before the listener exists and never loads its payload.onNuxtReadyon purpose so payload and chunk requests don't compete with hydration.ULinknow mirrorsNuxtLinkagain:onMounted→onNuxtReady→requestIdleCallback→ observe, with a guard so a link unmounted before hydration resolves never starts an observer.📝 Checklist