vercel / next.js

The React Framework
https://nextjs.org
MIT License
127.04k stars 27k forks source link

Next/Link is prefetching the current page being viewed #70535

Closed dannytlake closed 1 month ago

dannytlake commented 1 month ago

Link to the code that reproduces this issue

https://github.com/dannytlake/next-prefetch-bug-current-route

To Reproduce

Start in production mode, view network tab.

image

Current vs. Expected behavior

Current: The Next/Link component is prefetching the current page being viewed, unnecessarily consuming network + cpu resources

Expected: The Next/Link component should not prefetch links pointing to the current page being viewed.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:30 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T6000
  Available memory (MB): 32768
  Available CPU cores: 10
Binaries:
  Node: 20.16.0
  npm: 10.8.2
  Yarn: 1.22.22
  pnpm: 8.15.9
Relevant Packages:
  next: 15.0.0-canary.171 // Latest available version is detected (15.0.0-canary.171).
  eslint-config-next: 14.2.7
  react: 19.0.0-beta-26f2496093-20240514
  react-dom: 19.0.0-beta-26f2496093-20240514
  typescript: 5.5.4
Next.js Config:

Which area(s) are affected? (Select all that apply)

Navigation, Performance

Which stage(s) are affected? (Select all that apply)

next start (local), Vercel (Deployed)

Additional context

This bug also occurs in next@14 (v14.2.13 at time of writing)

samcx commented 1 month ago

@dannytlake Thank you for submitting an issue!

Our team is already looking to fix this issue :frog-eyes:

dannytlake commented 1 month ago

Thank you @samcx + @ztanner !

github-actions[bot] commented 1 month ago

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.