Cache poisoning issue during rapid test execution requires careful investigation of Next.js caching behavior.
The issue describes a cache poisoning problem where 404 responses bleed into valid page requests during rapid test execution. This requires understanding Next.js caching mechanisms and testing infrastructure, but has clear reproduction steps. The main challenge is diagnosing the root cause of the cache contamination.
https://codesandbox.io/p/devbox/bold-breeze-8dykdw
The link of the reproduction codesandbox does not actually trigger the bug. But shows the situation.
This is the scenario / bug:
I have three playwright e2e tests: a. Go to pokemon detail of bulbasaur b. Go to detail of nonexisting pokemon to test 404 this triggers the notFound() c. create pokemon via form client component which calls a server function that calls updateTags
Playwright runs the tests in chrome, firefox and safari
The second browser firefox fails the first test "Go to pokemon detail of bulbasaur" because it gets shown the 404 not-found.tsx page.
I go to /pokemon/1 manually and I can also sometimes get the 404 error.
I can only reproduce this locally with playwright, when it is running tests very rapidly.
What seems to happen is that there is a timing issue, somehow a 404 cache is assigned to a page that did not trigger the notFound(). I call this the poisoning of the cache. In other words /pokemon/1 seems to render the 404 result of /pokemon/1337.
I expect that notFound 404 pages are cached properly, and that they do not bleed over to pages that result in a 200.
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 25.3.0: Wed Jan 28 20:54:55 PST 2026; root:xnu-12377.91.3~2/RELEASE_ARM64_T6031
Available memory (MB): 36864
Available CPU cores: 14
Binaries:
Node: 24.12.0
npm: 11.6.2
Yarn: N/A
pnpm: N/A
Relevant Packages:
next: 16.2.0-canary.95 // Latest available version is detected (16.2.0-canary.95).
eslint-config-next: N/A
react: 19.2.4
react-dom: 19.2.4
typescript: 5.9.3
Next.js Config:
output: N/A
cacheComponents, Use Cache, Not Found
next start (loca
Claim this issue to let others know you're working on it. You'll earn 20 points when you complete it!