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

Page Reloads When Switching Pages After Rebuilding #75228

Open
build24001 opened this issue Jan 23, 2025 · 4 comments
Open

Page Reloads When Switching Pages After Rebuilding #75228

build24001 opened this issue Jan 23, 2025 · 4 comments
Labels
Linking and Navigating Related to Next.js linking (e.g., <Link>) and navigation.

Comments

@build24001
Copy link

Link to the code that reproduces this issue

https://github.com/build24001/test-layout

To Reproduce

1.Run npm run build
2.Run npm run start
3.Click on all Links in the Menus
4.Modify the content of the test page
5.Run npm run build again
6.Run npm run start again
7.Click on the test page => It has not been updated to the latest version
8.Refresh the browser
9.Click on other pages => The pages may be reloaded each time, potentially triggering a full page refresh

Current vs. Expected behavior

After rebuilding, clicking on the menu after refreshing the browser causes the page to reload, and there are RSC errors.

Image

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.1.0: Mon Oct  9 21:32:11 PDT 2023; root:xnu-10002.41.9~7/RELEASE_ARM64_T6030
  Available memory (MB): 18432
  Available CPU cores: 12
Binaries:
  Node: 18.20.1
  npm: 10.5.0
  Yarn: N/A
  pnpm: 9.7.0
Relevant Packages:
  next: 15.1.6 // Latest available version is detected (15.1.6).
  eslint-config-next: 15.1.5
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.7.3
Next.js Config:
  output: N/A

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

create-next-app

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

next build (local), next start (local)

Additional context

No response

@github-actions github-actions bot added the create-next-app Related to our CLI tool for quickly starting a new Next.js application. label Jan 23, 2025
@Onurfesci
Copy link

Onurfesci commented Jan 28, 2025

I'm experiencing the same thing, next.js seemingly randomly does hard navigation causing a full page reload. I'm on next 15.1.6 as well.

Most of the time, there's no error, sometimes there is the RSC error. This happens when I'm using router.push. I've tried router.prefetch but it still happens intermittently.

I get the error:

1517-4181b53f1bb2d603.js:1 Failed to fetch RSC payload for http://localhost:3000/register/account-type/choose. Falling back to browser navigation. TypeError: Cannot read properties of undefined (reading 'call')
    at r (webpack-310e74e27d689573.js:1:143)

In the Network, there are 2 rsc requests then a full document request
Image

Interestingly, when I do "Disable cache" in the chrome Network tab, it works perfectly - no hard navigation.

Unfortunately this has completely broken one of our step-by-step forms that we had nicely separated into logical routes, assuming next will handle everything on its end natively with navigation, which I'll have to fully refactor if this isn't resolved, along with many other parts of my app. :/

@samcx samcx added Link (next/link) and removed create-next-app Related to our CLI tool for quickly starting a new Next.js application. labels Jan 28, 2025
@samcx
Copy link
Member

samcx commented Jan 29, 2025

@build24001 I was not able to replicate the RSC payload errors on the latest canary. Can you share a video on how you replicated it?

I think the hard refresh is expected after you rebuild if current browser session was not refreshed. When prefetch is set to true, it should only be 1 refresh from the Home page.

@samcx samcx added Linking and Navigating Related to Next.js linking (e.g., <Link>) and navigation. and removed Link (next/link) labels Jan 29, 2025
@build24001
Copy link
Author

@samcx Sorry, I have improved the code.
https://github.com/build24001/test-layout
This is the video I recorded. I have tried setting prefetch to true, and the same issue occurred.

copy_FDCF7F79-BB84-46F2-8817-0E968220EAD7.MOV

The issue I'm encountering is similar to what @Onurfesci described. Due to the extensive use of router.push, after upgrading from Next.js 14 to 15, pages randomly refresh during navigation, forcing me to downgrade back to Next.js 14.

@Onurfesci
Copy link

For reference, I've also opened an issue with a reproduction: #75441

I think it may be exactly the same issue, the behaviour seems to be identical.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Linking and Navigating Related to Next.js linking (e.g., <Link>) and navigation.
Projects
None yet
Development

No branches or pull requests

3 participants