AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Intermittent 404 On Valid App Router Routes After Upgrading To Next.Js 16.2.9

After upgrading to Next.js 16.2.9, some valid routes intermittently return 404. The issue occurs under production load with PM2 and is resolved temporarily by refreshing. Likely caused by a race condition in the new route cache.

highConfidence 45%Next.jsAffected V16.2.9

Origin Analysis

A race condition in Next.js 16.2.9's route resolution cache, most likely triggered by concurrent requests (exacerbated by PM2 cluster mode or worker threads), causes valid routes to be temporarily missing from the cache and therefore return 404.
1. Upgrade an existing App Router application to Next.js 16.2.9. 2. Build and start the application with `pnpm build && pnpm start`. 3. Navigate between routes using Link components and direct URL access. 4. Observe that valid routes occasionally return a 404 page, although they work most of the time. 5. Refresh the page or navigate again to temporarily resolve the issue.

Fixing Code Block

Edge Case Audit

Disabling worker threads may reduce performance under high concurrency, as rendering becomes single-threaded. Monitor CPU usage and response times. If the root cause is not related to worker threads, the issue may persist. To rollback, remove the `workerThreads: false` line and revert PM2 configuration to the previous cluster setup. Apply this workaround only after confirming the intermittent 404s are not caused by other factors (e.g., missing route files, incorrect dynamic route configuration).

Ecosystem Topology