mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #614] [CLOSED] fix: detect dynamic API usage in route handlers to prevent stale ISR cache hits #712
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#712
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/614
Author: @southpolesteve
Created: 3/20/2026
Status: ❌ Closed
Base:
main← Head:fix/route-handler-dynamic-detection-v3📝 Commits (3)
43c65aefix: detect dynamic API usage in route handlers to prevent stale ISR cache hits0f38c50fix: clear pipeline dynamic usage before handler execution60b524ffix: separate proxy-based detection from pipeline dynamic usage📊 Changes
2 files changed (+336 additions, -21 deletions)
View changed files
📝
packages/vinext/src/entries/app-rsc-entry.ts(+48 -3)📝
tests/__snapshots__/entry-templates.test.ts.snap(+288 -18)📄 Description
Summary
Route handlers that access
request.headersorrequest.nextUrl.searchParamsare dynamic and should not be served from the ISR cache. This PR adds runtime dynamic detection matching Next.js behavior.Minimal diff: only changes
app-rsc-entry.ts(and snapshots). No changes toheaders.tsor the dynamic usage flag type.Changes
__proxyRouteRequest: Wraps theRequestin a Proxy. Accessing.headersor.nextUrl.searchParamscallsmarkDynamicUsage(). Methods are bound to the original target to preserve Web API internal slots.__dynamicRouteHandlers: ASetthat remembers route patterns whose handlers used dynamic APIs. The ISR cache read skips known-dynamic handlers. The Set grows monotonically for the process lifetime (intentional, matches Next.js which determines dynamism statically).Cache read guard:
!__dynamicRouteHandlers.has(handler.pattern)added to the ISR cache read condition.Background regen: Synthetic request is also wrapped in the Proxy, and dynamic detection adds to the Set.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.