Description
Environment
- nitropack
2.13.4(lockfile-resolved, latest release) — the gap also exists in v3main(presets/vercel/runtime/isr.ts, introduced via fix(vercel): handle ISR requests withpassQuery: true#3851) - Nuxt
4.4.8/@nuxt/[email protected] - Node
v25.9.0(repro script needs ≥ 20.11 forimport.meta.dirname), Bun1.3.14for install/build - Preset:
vercel(Build Output API v3)
Relevant config — any single isr route rule is enough:
routeRules: {
'/schedule': { isr: 300 },
}Reproduction
bun install
NITRO_PRESET=vercel bun run build
node scripts/local-repro.mjs # exits non-zero if any case divergesThe StackBlitz/CodeSandbox starters can't exercise this bug: it lives in the built Vercel function's runtime URL restoration, and reproducing it means invoking .vercel/output/functions/__fallback.func with the exact request shapes Vercel's router/prerender cache produces. scripts/local-repro.mjs does precisely that — it serves the built function locally and sends it each invocation shape, so the failure is deterministic with no deployment needed. The repo's CI runs this script on every push against the frozen lockfile: https://github.com/MichaelDickBasecom/nuxt-vercel-isr-404-repro/actions/workflows/local-repro.yml
A live deployment with all route-rule shape variants (static / dynamic param / catch-all / nested / passQuery) plus self-monitoring is linked from the README: https://nuxt-vercel-isr-404-repro.vercel.app
Describe the bug
On Vercel, Nitro implements isr route rules by rewriting the request to an internal prerender function (/schedule → /schedule-isr?__isr_route=/schedule) and reconstructing the original URL inside the function. Reconstruction is mandatory: Vercel invokes the function with req.url set to the rewritten dest path, and with a default isr: <seconds> rule the query string is stripped, so the URL-encoded groups in the undocumented x-now-route-matches header are the only carrier of the original URL.
The restoration in 2.13.4 (presets/vercel/runtime/vercel.mjs, decompiled for clarity) trusts that single carrier and gives up silently:
const isrRoute = req.headers["x-now-route-matches"];
if (isrRoute) {
const { __isr_route: url } = parseQuery(isrRoute);
if (url && typeof url === "string") {
if (getRouteRulesForPath(url).isr) req.url = url;
}
// gap 1: header present but no `__isr_route` → the query string is never
// consulted, even when it carries the correct value
} else {
// (query-string branch — only reached when the header is absent entirely)
}
// gap 2: bare invocation (no header, no query) → no recovery at allWhen restoration fails, the app renders its 404 page for the internal path (Page not found: /schedule-isr). On Vercel, 404 is a valid, storable ISR outcome (ISR docs, "On failure") — so the 404 is cached and served with x-vercel-cache: HIT until expiration (forever under isr: true). Verified live: revalidation of a poisoned entry re-invokes the function bare, re-caching the 404 indefinitely — a poisoned route does not heal until redeploy.
Behavior of the built function per invocation shape (this is what scripts/local-repro.mjs asserts):
| Invocation shape | Result |
|---|---|
header carries __isr_route (normal) |
200, correct page |
no header, __isr_route in query (passQuery shape) |
200, correct page |
header present without __isr_route — correct query param also present |
404 "Page not found: /schedule-isr" |
| bare invocation (no header, no query) | 404 "Page not found: /schedule-isr" |
Why this matters despite being hard to trigger today
This is the third time the same single-carrier weakness has shipped:
| nitropack | What happened | Status |
|---|---|---|
| 2.12.6 | -isr rename exposed a missing capture group for non-wildcard rules → internal path leaked |
fixed in 2.12.7 (#3595) |
| 2.12.6–2.12.9 | with passQuery/allowQuery, Vercel stops sending x-now-route-matches — these runtimes had no other carrier → every direct hit fails |
fixed in 2.13.0 (#3539) |
2.13.4 & v3 main |
single-carrier dependency, no fallback chain (gaps above) | open — this issue |
The header contract is undocumented and has demonstrably changed before (that change created the 2.12.x variant, and Vercel still omits the header entirely under passQuery today — verified live). Current versions survive only because the named group happens to be present in every carrier Vercel currently sends; a serialization variant emitting only positional groups (e.g. 1=schedule) is exactly the poisonous third row above.
Proposed fix, in priority order
- Fail safe (highest value): respond
503when the original URL cannot be recovered, instead of rendering the app's 404 for the internal path. Measured on a live deployment: 404/410 are stored by the ISR cache; 401/5xx are never stored and any existing good copy keeps serving (x-vercel-cache: STALE). A 503 turns an unrecognized future carrier shape into a transient miss instead of permanent cache poisoning — the only measure that defends against invocation shapes nobody has enumerated yet. - Consult the query string when the header lacks
__isr_route. Strictly additive — the rewrite writes the identical value into the dest query — and fixes the exact failing case in the repro without touching working paths. - (weakest) Strip the
-isrsuffix as a last resort — only works for static routes; a dynamic dest (/users/[id]-isr) strips to a route pattern, not a URL.
Prior art for a hardened design: Astro faced the same class of failure and hardened its ISR rewrite with a per-build token + internal-param stripping (withastro/astro#17370).
I'm happy to submit a PR for (1) + (2) against v3 main (and a 2.x backport if wanted) — scripts/local-repro.mjs in the repro repo is effectively the test for it.
Additional context
- Field reports with this symptom keep recurring and get misdiagnosed because
-isris just the internal function/cache-key name leaking into logs and error bodies. The repro repo's README separates three independent causes behind the identical user-visible symptom (404+x-vercel-cache: HITnaming-isr); this issue is the only one of the three that is a Nitro bug. Earlier reports in the lineage: 404 error on the root (/) route when using (ISR) on Vercel. #1287, Preset vercel: query params are ignored by cache #1880, nuxt#33316 → fix(vercel): always addurlto src regex forisrroutes #3595, Problem when using ISR passQuery on routeRules when deployed to Vercel #3594/Vercel ISR: Direct navigation to an ISR route returns 404 (Nuxt 4.1.3 / Nitro 2.12.7) #3651 → fix(vercel): handle ISR requests withpassQuery: true#3539. - Adjacent open items (narrower than this issue, not duplicates): Vercel ISR:
isrRouteRewritedrops the entire query string whenx-now-route-matchesis present (allowQuery/passQuery params never reach the render) #4408 / PR fix(vercel): correct ISR route rewrite query preservation and decoding #4409 (header branch drops the query string — the PR does not add a fallback chain), _payload.json-isr 404 on ISR routes deployed to Vercel #4047 (_payload.json-isrvariant; the bare-invocation payload case reproduces in the repro script as well). - How often the trigger fires today: the live deployment was monitored for ~2 days across ~318 revalidation boundaries, cold-cache races (8-way concurrent first hits), purge cycles, and Bun/Node runtimes — Vercel delivered a well-formed carrier every time. So on ≥ 2.13.0 this is a latent single point of failure on an undocumented contract, not a daily deterministic failure; on 2.12.6–2.12.9 (which lockfiles from ~Sept 2025–Jan 2026 still resolve) it fails deterministically with
passQuery/allowQuery— see branchdemo/p1-deterministicfor a browser-visible repro of that variant. - No external poisoning vector: outside requests to
/schedule-isr(even with a byte-identical?__isr_route=query) land on separate cache keys — the prerender cache is keyed on the original request path. Poisoning requires a malformed population/revalidation invocation, which is why the fail-safe (503) matters. - Only the Vercel preset is affected: it is the only preset that splits functions, rewrites paths, and reconstructs URLs at runtime (Netlify implements
isras SWR headers on one function; Cloudflare/AWS ignore the rule).
Logs
`node scripts/local-repro.mjs` against a fresh `NITRO_PRESET=vercel` build of nitropack 2.13.4 (2026-07-18):
as-expected status=200 control: /schedule via catch-all (trailing-slash workaround path)
as-expected status=200 header carries __isr_route (normal prerender invocation)
as-expected status=200 no header, query carries __isr_route (passQuery-style invocation)
as-expected status=404 BUG: header present WITHOUT __isr_route (query fallback shadowed)
→ server rendered "Page not found: /schedule-isr?__isr_route=/schedule"
as-expected status=404 BUG: no header, no query (bare prerender invocation)
→ server rendered "Page not found: /schedule-isr"
as-expected status=404 BUG: payload fn, bare invocation
→ server rendered "Page not found: /schedule/_payload.json-isr"
Mechanism confirmed: when the function cannot recover the original URL it renders
a 404 for the internal /…-isr path. On Vercel, 404 is a *valid, cacheable* ISR
outcome → it is stored and replayed with x-vercel-cache: HIT until expiration.
Activity
pi0x commentedon Sep 7, 2026
Your fix (2) is up as #4599 — the query string is now a fallback instead of being skipped whenever the header is present. Confirmed the gap on
mainfirst:isrRouteRewrite("/schedule-isr?__isr_route=/schedule", "0=schedule")returnedundefined, and does not any more.Fix (1), the 503, is left out deliberately. It needs a call on which requests count as an ISR invocation — the suffix check misfires on an app route literally named
*-isr, and the precise version means emitting the ISR function paths into the bundle at build time. That is a maintainer decision rather than a triage fix, so it is written up for @pi0 with a working patch rather than sent as a PR.Confirming the rest of your report reproduces on v3
mainas written.Posted by an AI triage agent on behalf of a maintainer.
fix(vercel): harden ISR URL restoration against carrier variants