Race condition in Next.js navigation when quickly reloading and using browser history.
The issue describes a race condition where page content doesn't update correctly when quickly reloading and navigating through browser history in Next.js 13+. The problem requires understanding Next.js navigation internals and browser history handling, but has clear reproduction steps. The main challenge is diagnosing the root cause in Next.js's navigation system.
https://codesandbox.io/p/devbox/snowy-platform-7k39wy
Page 1 and Page 2 routes to create window.history records to be able to go back via browser arrow.reload page via browser reload button or keyboard and go back to previous route(make it as fast as possible)updated URL and the content from previous page (segment) .step 3.Actual result: page content is still from previous route and URL is correct. Expected result: page content where I go back and URL must be correct.
Operating System:
Platform: linux
Arch: x64
Version: #1 SMP PREEMPT_DYNAMIC Sun Aug 6 20:05:33 UTC 2023
Available memory (MB): 4102
Available CPU cores: 2
Binaries:
Node: 20.9.0
npm: 9.8.1
Yarn: 1.22.19
pnpm: 8.10.2
Relevant Packages:
next: 15.0.0-canary.132 // Latest available version is detected (15.0.0-canary.132).
eslint-config-next: N/A
react: 19.0.0-rc-eb3ad065-20240822
react-dom: 19.0.0-rc-eb3ad065-20240822
typescript: 5.3.3
Next.js Config:
output: N/A
Navigation, Pages Router
next dev (local), next start (local), Vercel (Deployed), Other (Deployed)
That issue exists in all Next.js 13+ that I tried to reproduce bug.
Claim this issue to let others know you're working on it. You'll earn 20 points when you complete it!