-
Notifications
You must be signed in to change notification settings - Fork 27k
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
next/link sometimes does not update the page when used in dynamic page with replace and query parameters in v15 #69847
Comments
Thank you for the very clear reproduction, I'll have a fix up for this shortly. |
When returning an aliased prefetch, we need to make sure the final tree that is produced contains the final searchParams, as otherwise the router might not properly re-key the component to reflect the changed search value. This moves the existing util that handled appending `searchParams` to the `__PAGE__` segment into the shared segment helpers. On the client, when we detect that we returned an aliased prefetch, we update the segment key with the "final" data by calling this helper with the final searchParams. This also fixes a missing `aliased` detection in the case where we do find an entry as it's possible the entry matches the path, but not the search. It wasn’t sufficient to only do this for full prefetches because while auto prefetches won’t return the CacheNode data, it will return a tree, so we need to make sure the tree contains the right params. Fixes #69847
Thank you for the quick response and fix. I checked out the latest canary and it seems most issues are fixed 🎉. Unfortunately I encountered in some cases (depending on the order of the links) it still requires clicking the link twice. I added a new reproduction here https://github.com/skirsten/repro-next-link-broken/tree/bug2 and hosted here: https://repro-next-link-broken-git-bug2-skirsten.vercel.app/. I believe its related to the same logic. |
Indeed! Thanks for flagging, I’ll be taking a look at this soon. |
Awesome, I tested the canary and all the links behave as expected now. Thanks 🎉 I did notice one small inconsistency where some client side cache is used unexpectedly. Basically when returning to page 1 for the first time, its reusing the old page 1 (the timer will not start at 0). |
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. |
Link to the code that reproduces this issue
https://github.com/skirsten/repro-next-link-broken
To Reproduce
next build
andnext start
! It is not reproducible withnext dev
.Alternatively use this hosted url: https://repro-next-link-broken-git-bug1-skirsten.vercel.app/
Or checkout this video: https://github.com/user-attachments/assets/bfcee9ae-e95e-405e-89a1-83e8d4256538 (if you turn up the volume you can hear the mouse clicks)
Current vs. Expected behavior
I expect the links to work as they did in next v14 without problems.
Known working:
14.2.5
Not working in at least:
15.0.0-canary.144
15.0.0-canary.136
15.0.0-canary.128
Provide environment information
Operating System: Platform: linux Arch: x64 Version: #40~22.04.3-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 30 17:30:19 UTC 2 Available memory (MB): 32012 Available CPU cores: 16 Binaries: Node: 20.12.1 npm: 10.5.0 Yarn: 1.22.22 pnpm: 9.9.0 Relevant Packages: next: 15.0.0-canary.145 // Latest available version is detected (15.0.0-canary.145). eslint-config-next: 15.0.0-canary.145 react: 19.0.0-rc-7771d3a7-20240827 react-dom: 19.0.0-rc-7771d3a7-20240827 typescript: 5.5.4 Next.js Config: output: N/A
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
Unfortunately the nature of this bug is not very exact and sometimes changing the layout or order of the links changes how they will behave.
The text was updated successfully, but these errors were encountered: