Skip to content

fix(app-router): enforce dynamicParams = false for route handlers - #4125

Merged
james-elicx merged 20 commits into
fix/dynamic-params-route-miss-not-foundfrom
fix/route-handler-dynamic-params-stacked
Nov 9, 2026
Merged

james-elicx merged 20 commits into
fix/dynamic-params-route-miss-not-foundfrom
fix/route-handler-dynamic-params-stacked

Conversation

@james-elicx

@james-elicx james-elicx commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Summary

A route handler (route.ts) that exports dynamicParams = false together with generateStaticParams ran for any param value. Pages and generated metadata images in the same segment already returned 404 for unlisted params, but a sibling route handler answered 200 with whatever it returned for the unlisted slug.

Next.js gates these handlers on its prerender manifest (build/templates/app-route.ts: fallback === false && !isPrerendered → NoFallbackError), so an unlisted param gets the unmatched-URL 404.

This is stacked on #4122, which gives dynamicParams = false page misses Next's routing-level not-found. The route handler 404 now goes through the same path. It supersedes #4123, which fixed the same gap independently. Its policy, tests and fixtures are ported here and use #4122's shared mechanism, with the gaps listed below closed.

Fix

  • Policy: shouldEnforceAppRouteHandlerStaticParams() (app-route-handler-policy.ts) ports the cases where Next.js lists a route handler with fallback: false. Only the handler's own exports count, because layouts don't apply to route handlers.
    • Dev: any handler with dynamicParams = false and generateStaticParams.
    • Production: routes that bail out of static generation are left out, i.e. dynamic = "force-dynamic", revalidate = 0, or exporting POST/PUT/DELETE/PATCH/OPTIONS. Those methods only bail out while a generated path prerenders. So when generateStaticParams returns [], Next still lists the route with fallback: false and 404s every param. vinext runs the generator for these routes to tell the two cases apart. Without generateStaticParams, only force-static / error routes are listed, and they 404 every param.
    • Edge runtime: skipped in production. Next.js never prerenders edge routes, and rejects runtime = "edge" together with generateStaticParams at build time.
    • Draft mode: skips the check, as in Next.js.
  • Param check: dispatchAppRouteHandler() checks params with the shared validateAppPageDynamicParams().
    • Route handlers receive decoded params, and Next.js admits by decoded value. Re-encoding them gives the encoded form pages compare. For example, /x/public%2520post is admitted only when "public%20post" is listed.
    • Required and optional catch-all param names come from the route pattern.
    • The check runs after a route-cache miss. Only admitted params are ever cached, so a hit doesn't call generateStaticParams. It still runs before the 400, auto-OPTIONS and 405 responses, as in Next.js.
  • Fallback rewrites: as for pages in fix(app-router): render dynamicParams misses as a routing-level not-found #4122, an app with fallback rewrites checks a route handler's params while routing, so a fallback rewrite can claim a rejected param, as in Next.js. The rule is shared through isAppRouteHandlerParamsMiss(), and routing decides draft mode as the dispatch does (the live headers context, then the request). An admitted match passes skipStaticParamsValidation, so the generator runs once.
  • Generation: like Next.js, the generator runs with only the handler's fetchCache (no revalidate or force-dynamic default), in a scope of its own. headers(), cookies(), connection() and draftMode() (reading it included) reject there, as Next's generate-static-params work unit makes them throw, so a generator can't list a param from the request. It runs in that work unit, so io() resolves and revalidateTag() / revalidatePath() throw, as in Next, also from a "use cache" function the generator calls. cacheForRequest() values aren't shared between the generator and the request, and the generator memoizes its own fetches whichever branch runs it. Like Next's build store, it reads cached data even when the request is an on-demand revalidation, and its fetches carry the route handler's own implicit tags rather than the request pathname's. A cached function the generator calls keeps Next's cache-scope rules: it reads draft mode as disabled, a caught connection() error still fails it, and "use cache: private" is rejected outside a request. The generator never reads the request's private cache. Like Next's AfterRunner, the generator's after() work finishes before its params are checked, and a failed task fails the generation. Dynamic usage (a no-store fetch) stays out of the request, so a fallback rewrite's target isn't marked dynamic by the rejected handler's generator. It sees no root params from the request, because a route's own generator has no parent params, and its fetches add no tags, revalidate or dynamic-fetch observations to the request the handler then serves. For the "returns []" case, a row counts only when it fills every pathname param and has no empty required segment, as in Next's static paths. A listed param named __proto__ is admitted.
  • Draft cookies: a rejected param's rendered 404 keeps a draft-mode transition that middleware started, such as the deletion cookie from draftMode().disable().
  • The 404: the same never-cached root not-found as an unmatched URL, with empty navigation and root params. Both the combined handler and the split response stage pass a renderNotFound callback for it. The handler's fetch defaults and soft tags (fetchCache, revalidate, dynamic) are cleared before it renders, as they are for an unmatched URL. Because the response is the not-found page, next.config headers meet it with page rules rather than the Route Handler collision rules from fix(app-router): resolve next.config header collisions with Route Handler headers like Next.js #4528, both directly and through the response stage. A redirect thrown while it renders (say, by the root layout) still counts as an application response, so it gets config headers like the same redirect on an unmatched URL.
  • Handler responses can't forge the marker: an x-vinext-route-miss header that a handler's own response carries (for example a proxied fetch()) is dropped after the response completes, so a header the body's producer adds while streaming is dropped too. It never reaches the request stage or the route cache, and a stored route response drops it when read.
  • Shared route-miss marker: markRouteMissResponse() (route-miss-response.ts) now marks both page and route handler misses with fix(app-router): render dynamicParams misses as a routing-level not-found #4122's x-vinext-route-miss marker. The request stage strips the marker, reasserts never-cache after config and middleware headers, and relabels the request trace as /404. Compared with fix(app-router): enforce dynamicParams = false for route handlers #4123, this:

Verified against real Next.js 16.2.7 (in #4123: next build --webpack / next start, and next dev)

route handler (unlisted param) Next prod Next dev vinext prod / dev
static GET + dynamicParams=false + gSP 404 (not-found page) 404 404 / 404
same, OPTIONS 404 404 404 / 404
+ dynamic="force-dynamic", revalidate=0, or exports POST 200 404 200 / 404
+ POST/PUT/OPTIONS, gSP returns [] (checked locally with next build --webpack / next start) 404 404 404 / 404
+ force-dynamic or revalidate=0, gSP returns [] (same check) 200 404 200 / 404
+ draft mode cookie 200 200 200 / 200
+ a matching rewrites().fallback (checked with this PR's fixture shape) 200, rewrite target same same
no gSP 200 200 200 / 200
no gSP + dynamic="force-static" / "error" 404 200 404 / 200
[[...slug]] with gSP [{slug:["a"]}], request / 404 404 404 / 404

Tests

  • Fixtures: tests/fixtures/app-basic/app/metadata-static-params/[slug]/data/route.ts mirrors the route-handler half of Next.js' own fixture for this case, including the encoded rows its sibling page and image use. dynamic-data/route.ts is the force-dynamic variant.
  • Production e2e: tests/e2e/app-router/isr.spec.ts "route handlers honor dynamicParams=false" covers listed/encoded/unlisted params, OPTIONS, the not-found body and cache-control, force-dynamic being served, and draft mode skipping the check. Against fix(app-router): render dynamicParams misses as a routing-level not-found #4122's source alone, it fails (unlisted param → 200).
  • Fallback rewrites e2e: segment-cache-dynamic-params.spec.ts adds a dynamic-params-fallback/[slug]/data/route.ts handler with a fallback rewrite. A listed param reaches the handler, an unlisted one reaches the rewrite target (this fails before the fix with a 404), and in draft mode the handler answers the unlisted param. Runs in dev and production.
  • Dev integration: tests/app-router-metadata-routes.test.ts.
  • Unit:
    • app-route-handler-policy and app-route-handler-dispatch: decoded comparison, the optional catch-all, a cache hit skipping generateStaticParams, dev without gSP, edge runtime. The 404 also stays out of a split stage's shared cache under a public config CDN policy; this test fails without the storage veto. The 404 renders without the handler's fetch state, and a handler-set marker is dropped from live responses (mutable headers, immutable headers, and one the body's producer adds while streaming) and from regenerated ones. The generator runs without the request's root params and fetch state, with the handler's fetchCache before an auto-OPTIONS response, memoizes a mixed-method generator's repeated fetch, reads its cached fetch during an on-demand revalidation, tags fetches with the route's implicit tags, keeps the cache-scope rules above, and ignores rows that list no concrete path. Each of these fails without its fix.
    • app-rsc-handler: the route handler 404's never-cache policy, render context, single application of config headers and /404 trace, both direct and through the response stage.

Known limitations

  • Runtime-only dynamic handlers: a handler that only becomes dynamic at runtime still 404s unlisted params in production, as in Next dev. Examples are reading request.headers, request.url or search params, calling cookies() / headers(), or a no-store fetch. Next production serves those params, because its build-time prerender bails out and drops the manifest entry. vinext can't know this before running the handler.
  • Cached responses: as for pages and image metadata routes (documented in docs/reference/differences.mdx), a route-cache hit is served without the check unless the app has fallback rewrites, in which case routing runs the generator for every request, hits included. Cache keys include the build ID, so this only matters with a pinned generateBuildId and a cache that persists across deploys. The docs sentence now names route handlers too.
  • Fallback destinations that miss: if a fallback rewrite's destination is itself a dynamicParams = false route that rejects the param, Next resumes routing with the later fallback rewrites. vinext renders that route's 404. Like fix(app-router): render dynamicParams misses as a routing-level not-found #4122's other-dynamic-routes limitation, this needs routing to resume after a miss, which is left for a follow-up.
  • Pages' generators: page generateStaticParams still runs with the request's root params and request APIs, and, outside fix(app-router): render dynamicParams misses as a routing-level not-found #4122's fallback-rewrite routing check, its fetch state. That predates this stack and is left for a follow-up.
  • Multi-stage Worker output: as for pages in fix(app-router): render dynamicParams misses as a routing-level not-found #4122, its request stage can't run the check, so fallback rewrites can't claim a route handler miss there.
  • Empty generateStaticParams: returning [] 404s every param in vinext dev and prod. Next prod also 404s, but Next dev serves.

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues. Review head SHA 340d365. You have an 8-minute time limit.

@pkg-pr-new

pkg-pr-new Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@vinext/cloudflare

npm i https://pkg.pr.new/@vinext/cloudflare@4125

create-vinext-app

npm i https://pkg.pr.new/create-vinext-app@4125

@vinext/types

npm i https://pkg.pr.new/@vinext/types@4125

vinext

npm i https://pkg.pr.new/vinext@4125

@cloudflare/workers-response-store

npm i https://pkg.pr.new/@cloudflare/workers-response-store@4125

commit: a6a18de

@github-actions

Copy link
Copy Markdown
Contributor
Example Preview Production Original
app-router-cloudflare preview production
pages-router-cloudflare preview production
app-router-playground preview production original
realworld-api-rest preview production
nextra-docs-template preview production
benchmarks preview production
hackernews preview production original
response-store-demo preview production
workers-cache preview production
kv preview production
static-assets-cache preview production
static-assets-pages preview production
static-assets-pages-i18n preview production
static-export preview production
web preview production

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Performance benchmarks

Compared 51fb64e against base f691ab6 using alternating same-runner rounds. Next.js was unchanged and skipped.

0 improved · 0 regressed · 7 within ±1.5%

Scenario Framework Baseline Current Change
Client bundle size (gzip) vinext 153.5 KB 153.5 KB ⚫ 0.0%
Client entry size (gzip) vinext 141.7 KB 141.7 KB ⚫ 0.0%
Dev server cold start vinext 2.22 s 2.25 s ⚫ +1.1%
Dev server cold start (large Pages Router app) vinext 18.51 s 18.68 s ⚫ +0.9%
Production build time vinext 2.85 s 2.84 s ⚫ -0.3%
RSC entry closure size (gzip) vinext 142.1 KB 142.6 KB ⚫ +0.3%
Server bundle size (gzip) vinext 251.3 KB 252.9 KB ⚫ +0.7%

View detailed results and traces

🟢 improvement · 🔴 regression · ⚫ change below 1.5% · paired base/head

}
}

const unlistedParamsResponse = await rejectUnlistedParams();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The static-param gate runs after the ISR read, so an existing entry for an unlisted path still returns 200. This is reachable when a persisted data-cache entry was written before dynamicParams = false (or before this fix) because appIsrRouteKey() contains only the pathname/route suffix, not the build ID; Next checks fallback === false && !isPrerendered before its response cache lookup. Please validate before accepting a cache hit, or otherwise prove the cached path belongs to the current generated-param set.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declining this one. Route-cache keys include the build ID (appIsrCacheKey prefixes app:v2:${buildId}), so an entry stored for params that a later deploy removes isn't read by that deploy. That only fails with a pinned generateBuildId plus a cache that persists across deploys. Pages and image metadata routes behave the same way, and docs/reference/differences.mdx documents it as a design decision. Calling generateStaticParams on every hit would undo the runtime-generator tradeoff documented there. In 34bce3b the docs sentence now names route handlers too, and the PR's known limitations list it.

route,
searchParams: resolvedSearchParams,
});
return withRouteMissCacheControl(routeHandlerResponse);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now treats a header authored by an ordinary Route Handler as trusted framework state. A handler can return x-vinext-route-miss: 1; this branch then relabels the request /404 and forces no-store. In split mode, completed-response admission occurs inside the response stage before this outer call, so a cacheable forged response can also be stored with the marker and replayed. Strip this reserved header from user Route Handler responses before cache admission, while preserving the marker added by markRouteMissResponse().

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 34bce3b. stripAppRouteHandlerRouteMissMarker() drops the marker from the handler's own response right after assertSupportedAppRouteHandlerResponse. It runs on both the live path (app-route-handler-execution.ts) and background regeneration (app-route-handler-cache.ts), so the marker can't reach the request stage or the route cache. Immutable headers, such as on a proxied fetch() response, are rebuilt. markRouteMissResponse() adds its marker later, so it's unaffected. Tests cover mutable and immutable live responses and a regenerated write, and fail without the fix.

params: {},
});
setRootParams({});
return renderUnmatchedRoute();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resetting navigation/root params is not enough to make this equivalent to an unmatched route. Before this callback, the outer handler installed route soft tags and dispatchAppRouteHandler() installed the rejected handler’s fetchCache, revalidate, and force-dynamic defaults. Any fetch or use cache call made while rendering the root not-found therefore inherits the rejected Route Handler’s cache policy/tags; a real unmatched URL reaches renderUnmatchedRoute() without those settings. Reset the fetch-cache state for the fallback in both direct and response-stage paths.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 34bce3b. rejectUnlistedParams clears the fetch soft tags, cache mode, revalidate and force-dynamic default before rendering the 404. It's in dispatch, so this covers both the direct and the response-stage paths. A test records the request context inside renderNotFound for a fetchCache: "force-cache", revalidate: 60 handler, and it fails without the reset.

@ask-bonk

ask-bonk Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Review: 3 findings.

Posted 3 actionable inline comments.

github run

@james-elicx
james-elicx force-pushed the fix/route-handler-dynamic-params-stacked branch 2 times, most recently from c19e547 to 34bce3b Compare October 20, 2026 20:21
@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues. Review head SHA 34bce3b. You have an 8-minute time limit.

const handlerResult = tracedResult.handlerResult;
let { dynamicUsedInHandler, response } = handlerResult;
assertSupportedAppRouteHandlerResponse(response);
response = stripAppRouteHandlerRouteMissMarker(response);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The marker is stripped before response completion, but this codebase explicitly permits stream producers to mutate headers while the body is consumed (see the snapshot at lines 451-454). A handler can return a stream whose pull() re-adds x-vinext-route-miss; completeAppRouteHandlerResponse() then rebuilds from the post-EOF headers, so the forged marker still reaches the ISR write/shared-cache admission and the outer trusted-marker branch. I verified the same Web Response sequence locally: delete before arrayBuffer(), re-add from pull(), and the completed response contains the marker. Strip again from the completed response immediately before policy/cache handling, and do the same after completion in background regeneration; please add a late-stream mutation test.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in ee463fc. The strip now runs on the completed response, right after completion and before the policy snapshot, ISR write and cacheability admission. It also runs on completed.response before the background-regeneration cache write. The tests use a lazy stream (highWaterMark: 0) whose pull() re-adds the marker, on both the live and regeneration paths. They fail with the earlier pre-completion strip.

@ask-bonk

ask-bonk Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Review: 1 findings.

Posted 1 actionable inline comment.

github run

@james-elicx
james-elicx force-pushed the fix/route-handler-dynamic-params-stacked branch from 34bce3b to ee463fc Compare October 20, 2026 20:29
@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues. Review head SHA ee463fc. You have an 8-minute time limit.

// Response.redirect() and similar responses have immutable headers.
const headers = new Headers(response.headers);
headers.delete(VINEXT_ROUTE_MISS_HEADER);
return new Response(response.body, {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebuilding an immutable proxied response with this plain init drops Workerd-only response state. This repository's request-tracing.ts explicitly uses new Response(response.body, response as ResponseInit) because Workerd copies cf, webSocket, and encodeBody; losing the latter can double-encode a body, and losing webSocket breaks an upgrade response whenever the upstream happened to return this reserved header. Rebuild from response as ResponseInit, then delete the marker from the new mutable headers.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 27782a6. The immutable-header fallback now rebuilds with new Response(response.body, response as ResponseInit), as updateResponseHeader in request-tracing.ts does, so Workerd keeps cf, webSocket and encodeBody. It then deletes the marker from the new headers. The rebuild also keeps the fully-buffered body metadata and the Link-header provenance. A unit test checks that the original response is the init and the marker is gone. It fails with the plain-init rebuild.

@ask-bonk

ask-bonk Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Since last review: 1 resolved, 0 still open, 1 new.

Posted 1 actionable inline comment.

github run

@james-elicx
james-elicx force-pushed the fix/route-handler-dynamic-params-stacked branch from ee463fc to 27782a6 Compare October 20, 2026 20:37
@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues. Review head SHA 27782a6. You have an 8-minute time limit.

if (!hasGenerateStaticParams) {
return handler.dynamic === "force-static" || handler.dynamic === "error";
}
return !hasNonStaticAppRouteHandlerMethods(handler);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This exemption is only valid when at least one generated path actually prerenders and the mixed-method route bails out. When generateStaticParams() returns [], Next still emits the dynamic route with fallback: false (its build has no generated path on which a non-static method can trigger a bailout), so every parameter returns 404. Here hasNonStaticAppRouteHandlerMethods() makes vinext run the handler for every parameter instead, contradicting the PR’s stated empty-generator parity. Please distinguish an empty generated set before applying the mixed-method exemption and add a production test for dynamicParams = false, generateStaticParams: () => [], and POST.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in f7c3136. I confirmed it with a local next@16.2.7 next build --webpack / next start. With dynamicParams = false and generateStaticParams: () => [], POST, PUT and OPTIONS exports all build as ● with fallback: false and 404 every param. With one generated path, a POST export builds as ƒ and serves. force-dynamic and revalidate = 0 serve even with []. The policy (resolveAppRouteHandlerStaticParamsEnforcement) now returns enforce-when-none-generated for production mixed-method routes, and dispatch runs the generator to decide. A production-mode dispatch test covers [] + POST (404, handler not run) and a generated path + POST (served). It fails without the fix. The PR's verification table has both cases.

@ask-bonk

ask-bonk Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Since last review: 1 resolved, 0 still open, 1 new.

Posted 1 actionable inline comment.

github run

@james-elicx
james-elicx force-pushed the fix/route-handler-dynamic-params-stacked branch from 27782a6 to f7c3136 Compare October 20, 2026 20:48
@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues. Review head SHA f7c3136. You have an 8-minute time limit.

const enforcement = resolveAppRouteHandlerStaticParamsEnforcement(handler, isProduction);
if (enforcement === "skip") return null;
if (enforcement === "enforce-when-none-generated") {
const generated = await (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When this first call returns [], execution falls through to validateAppPageDynamicParams(), which invokes the same generateStaticParams function again. That duplicates user data-fetching/side effects on every mixed-method miss, and a stateful generator can return [] first and rows second, causing vinext to admit a path even though Next’s single build-time result produced fallback: false. Please reuse the generated result for validation, or directly render the miss once this call has established that the result is empty; add a call-count assertion to the new test.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in d0f0e4a. Once the single generateStaticParams call for a mixed-method route returns no rows, dispatch renders the miss directly and doesn't call validateAppPageDynamicParams. The generator now runs exactly once per request on both branches. The test asserts one call for the empty generator (404) and one for the generated one (served). It fails on the previous head.

@ask-bonk

ask-bonk Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Since last review: 1 resolved, 0 still open, 1 new.

Posted 1 actionable inline comment.

github run

@james-elicx
james-elicx force-pushed the fix/route-handler-dynamic-params-stacked branch from f7c3136 to d0f0e4a Compare October 20, 2026 20:52
@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues. Review head SHA d0f0e4a. You have an 8-minute time limit.

const headers = new Headers(response.headers);
applyCdnResponseHeaders(headers, { cacheControl: NEVER_CACHE_CONTROL });
headers.set(VINEXT_ROUTE_MISS_HEADER, "1");
return preserveFullyBufferedBodyMetadata(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

markRouteMissResponse() reconstructs the response but does not copy the renderer-owned Link provenance attached to response.headers. A rendered root not-found can carry CSS/preload links; after this wrapper, finalizeAppRscResponse() sees hasPostConfigLinkHeaders() as false, so a matching next.config Link header replaces those renderer links instead of being prepended. This affects both page and route-handler misses now that they share this helper. Please call copyLinkHeaderProvenance(response.headers, headers) before constructing the marked response, as the other response wrappers do.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 9165cc7. The wrapper code came from #4122, so I fixed it at the bottom of the stack in 3f99cdf and rebased. markRouteMissResponse() now copies Link provenance onto the marked response's headers. The provenance is a WeakMap keyed by the Headers object, so it's copied onto the final response, not the intermediate init. The request stage's immutable-headers fallback in withRouteMissCacheControl copies it too. Tests: the page miss keeps renderer Link provenance, and an end-to-end handler test on an immutable not-found expects config Link to be prepended before the not-found's own. Both fail without the fix.

@ask-bonk

ask-bonk Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Review: 1 findings.

Posted 1 actionable inline comment. Targeted tests pass: 493 tests.

github run

@james-elicx
james-elicx force-pushed the fix/route-handler-dynamic-params-stacked branch from d0f0e4a to 9165cc7 Compare October 20, 2026 21:03
A route handler exporting dynamicParams = false with generateStaticParams
ran for any param value. Next.js rejects unlisted params while routing and
serves the unmatched-URL 404, so route handlers now do the same, using the
routing-level not-found that dynamicParams page misses already use.

Both misses share one marker, so the request stage reasserts the never-cache
policy, shared-cache admission never stores the 404, and the request is
traced as /404 rather than the rejected route.
… its own

Like Next.js, a route handler's generateStaticParams sees no root params
from the request, and its fetches add no tags or dynamic-fetch
observations to the request the handler then serves. A stored route
response also drops the framework's route-miss marker.
…n guard and request cache separate from the request
…tch memoization outside an on-demand revalidation
…taticParams

A cached function a route handler's generateStaticParams calls reads draft
mode as disabled, still fails to store what it computed after a caught
connection() error, and "use cache: private" is rejected outside a request,
as in Next.js. The generator no longer reads the request's private cache.
@james-elicx
james-elicx force-pushed the fix/route-handler-dynamic-params-stacked branch from 9d38011 to a6a18de Compare November 9, 2026 06:08
@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

Please review exact head a6a18ded9107c5aa9fec2a035627a52cdc482b91 without modifying or pushing the branch. Report all actionable findings within your 8-minute time limit.

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Approved — No findings. The cache-scope changes since the last review (disabled draft mode in a cached function, connection() checking the cache scope first, and rejecting "use cache: private" in generateStaticParams) are correct and each has a regression test.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🔒 Security: ✅ LGTM

The generator can't read the request's private cache, and its request APIs stay blocked. The route-miss marker still can't be forged by a handler's response.


📖 AGENTS.md: ✅ LGTM

Runtime logic stays in server/* and shims/*. The generated entry only adds thin wiring.


📋 Code Quality: ✅ LGTM

The cache-scope rules for a route handler's generateStaticParams are consistent across draftMode(), connection() and the private cache boundary.


⚡ Performance: ✅ LGTM

No new hot-path cost. The added checks are a cheap work-unit lookup.


📝 Documentation: ✅ LGTM

No documentation issues.


Reviewed commit: a6a18ded

@ask-bonk

ask-bonk Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

LGTM!

github run

@james-elicx
james-elicx added this pull request to stack #4632 November 9, 2026 15:44
@james-elicx
james-elicx merged commit 9da80b0 into main Nov 9, 2026
132 of 231 checks passed
@james-elicx
james-elicx deleted the fix/route-handler-dynamic-params-stacked branch November 9, 2026 21:16
@github-actions github-actions Bot mentioned this pull request Nov 9, 2026
MrIago added a commit to MrIago/vinext that referenced this pull request Nov 14, 2026
38 upstream commits. Conflicts resolved file by file, keeping the
official code wherever upstream solved the same problem, and layering
ours on top only where it adds behavior:

- app-page-dispatch: upstream's routing-level dynamicParams miss
  (cloudflare#4122, cloudflare#4125, cloudflare#4634) replaces our boundary render, and its draft-mode
  skip supersedes ours (cloudflare#3547). Our parameter matching admission still
  gates the check.
- action-owner-manifest: upstream's sourcemap-preserving rewrite (cloudflare#4679)
  replaces our MagicString fix; the file now equals upstream.
- app-rsc-handler: upstream moved the unmatched-route render into a
  helper; our percent-escaping of the cache path match (670fa02) is
  re-applied there.
- link / app-router-navigation: upstream's Cache Components-only dynamic
  shell (cloudflare#4660) combined with our static shell prefetch stages.
- fetch-cache / cache / cache-runtime: upstream's cacheRead token (cloudflare#4642)
  threaded through our resume data cache reads.
- deploy: our --mode support next to upstream's version annotations
  (cloudflare#4689).
- prerender: upstream's forked prerender server (cloudflare#4687, cloudflare#4695) with our
  fallback-shell error handling; tests use `_prodServer: { port }`.
- use-cache-callable: keeps the removal of the layout/template default
  exclusion from the Cache Components resume stack.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant