vercel / next.js

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

next/link has a incorrect prefetch, even though set the <Link prefeth={false} target="_selft" href="https://samedomain.com/path-b" /> #67375

Open lomocc opened 3 days ago

lomocc commented 3 days ago

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/xenodochial-link-5g95h4

To Reproduce

  1. create A project, add component: <Link prefeth={false} target="_selft" href="https://samedomain.com/path-b" />
  2. build and start production
  3. debug in chrome with: window.addEventListener("beforeunload", function() { debugger; }, false)
  4. click link
  5. switch to Chromenetwork tab, you can see a incorrect prefetch before page refresh
  6. if the href is come from B project, the tree data is also incorrect.

Current vs. Expected behavior

should disable prefetch. which called navigateReducer -> getOrCreatePrefetchCacheEntry -> createLazyPrefetchEntry -> fetchServerResponse

Provide environment information

"next": "^14.2.4"

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

Navigation

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

next start (local), Vercel (Deployed), Other (Deployed)

Additional context

No response

wyattjoh commented 3 days ago

I was able to open your sandbox and inspect the code, but it doesn't seem like there's any issue with the current behaviour. Right now, when passing prefetch={false} it does not send a prefetch RSC request for the page. Instead, it just sends the regular RSC request when clicking, which is correct.

lomocc commented 3 days ago

I was able to open your sandbox and inspect the code, but it doesn't seem like there's any issue with the current behaviour. Right now, when passing prefetch={false} it does not send a prefetch RSC request for the page. Instead, it just sends the regular RSC request when clicking, which is correct.

but, For project b, got the Next-Router-State-Tree parameter for project a. I am currently experiencing a 500 error in the real project. I don't have the ability to reproduce this issue in codesandbox.

My core point is that the next/link of project a passes the Next-Router-State-Tree parameter of project a, but project b doesn't support it. prefetch=false doesn't change it either.