Skip to content
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

<Link prefetch={false}> not work as expected #67375

Open
lomocc opened this issue Jul 2, 2024 · 2 comments
Open

<Link prefetch={false}> not work as expected #67375

lomocc opened this issue Jul 2, 2024 · 2 comments
Labels
bug Issue was opened via the bug report template. Navigation Related to Next.js linking (e.g., <Link>) and navigation.

Comments

@lomocc
Copy link

lomocc commented Jul 2, 2024

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

@lomocc lomocc added the bug Issue was opened via the bug report template. label Jul 2, 2024
@github-actions github-actions bot added the Navigation Related to Next.js linking (e.g., <Link>) and navigation. label Jul 2, 2024
@wyattjoh
Copy link
Member

wyattjoh commented Jul 2, 2024

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
Copy link
Author

lomocc commented Jul 3, 2024

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.

@lomocc lomocc changed the title next/link has a incorrect prefetch, even though set the <Link prefeth={false} target="_selft" href="https://samedomain.com/path-b" /> <Link prefetch={false}> not work as expected Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. Navigation Related to Next.js linking (e.g., <Link>) and navigation.
Projects
None yet
Development

No branches or pull requests

2 participants