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

Router.Refresh() Silently No-Ops On Streamed Pages With Query Strings In Next.Js App Router

In Next.js production builds (App Router), router.refresh() fails to trigger a server round-trip when the current page was streamed and the URL contains a query string. This causes stale UI after mutations on filtered list pages, with no fetch initiated. The issue is present across multiple versions, with 16.2.12 only affected for query-string URLs, and 16.3.5+ affected for all streamed pages. A fix requires forcing cache invalidation for the current URL during refresh.

highConfidence 72%Next.jsAffected V16.1.7Affected V16.2.12Affected V16.3.5Affected V16.4.0-Canary.37

Origin Analysis

The refresh reducer reuses the existing segment cache entry for the current canonical URL when handling a refresh action. If the page was streamed and the response was cached under a key that includes the query string (or the cache state is marked fresh prematurely during streaming), the router considers the cached Flight data valid and skips the network request. This is exacerbated by a recent change (PR #94144) that altered how search params are stored in the cache, leading to incorrect freshness checks for query-string URLs and for streamed pages in newer canary/stable releases.
1. Clone https://github.com/Aabshir/next-refresh-query-repro 2. npm install && npm run build && npm start 3. Open / and click 'Mutate + refresh' several times — observe stamp does not update on most versions. 4. Open /?status=draft and repeat — stamp never updates even on 16.2.12. 5. Verify via CDP network capture that no _rsc fetch is initiated after the mutation POST.

Fixing Code Block

Edge Case Audit

This hotfix forces a full cache eviction on every refresh, which may increase server load in high-frequency refresh scenarios. It also assumes the cache object implements a `delete` method; if the internal cache representation changes, this patch will need adjustment. For rollback, revert the patch—no persistent state is altered. Additionally, this fix may reintroduce the original cache efficiency loss; monitor for unexpected prefetch behavior in apps that rely on aggressive segment caching.

Ecosystem Topology