Error: Invariant: attempted to hard navigate to the same URL #65561
Labels
bug
Issue was opened via the bug report template.
Navigation
Related to Next.js linking (e.g., <Link>) and navigation.
Link to the code that reproduces this issue
https://github.com/igorwessel/next14-canary-hard-navigate-issue
To Reproduce
Current vs. Expected behavior
I expected Next.js to perform a hard-refresh when it receives a 404 status code from the JSON of the dynamic route, similar to what happens when it navigates to another page. However, I observed that the error
Error: Invariant: attempted to hard navigate to the same URL
is thrown.Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 23.4.0: Fri Mar 15 00:10:42 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6000 Available memory (MB): 16384 Available CPU cores: 8 Binaries: Node: 18.20.1 npm: 10.5.0 Yarn: 1.22.22 pnpm: 8.15.7 Relevant Packages: next: 14.3.0-canary.51 // Latest available version is detected (14.3.0-canary.51). eslint-config-next: N/A react: 18.3.1 react-dom: 18.3.1 typescript: N/A Next.js Config: output: standalone
Which area(s) are affected? (Select all that apply)
Navigation
Which stage(s) are affected? (Select all that apply)
Other (Deployed)
Additional context
Occurs in next@12.3.4 too
From our understanding of the previous issue, Next.js should perform a hard-refresh when it receives a 404 while trying to perform data-fetching on a dynamic page with some data-fetching method like getServerSideProps. Currently, this error occurs on the same page, but it does not happen if we go to another page.
If this is not a bug, how can we solve this problem/mitigate given that requests to
.next/data/{buildId}
are dynamic?Gravacao.de.Tela.2024-05-09.as.07.08.09.mov
The text was updated successfully, but these errors were encountered: