Skip to content

fix: avoid /index cache-key collision for root dynamic routes#94326

Open
YoussefMansour9 wants to merge 2 commits into
vercel:canaryfrom
YoussefMansour9:canary
Open

fix: avoid /index cache-key collision for root dynamic routes#94326
YoussefMansour9 wants to merge 2 commits into
vercel:canaryfrom
YoussefMansour9:canary

Conversation

@YoussefMansour9
Copy link
Copy Markdown

When a root-level dynamic route (e.g., [slug] with dynamicParams: true) coexists with / and the / page has a stale ISR cache, a request to /index is handled by [slug] but its resolvedPathname is normalized to /, causing the ISR cache key (ssgCacheKey) to collide with the / page. The [slug] notFound() result then overwrites the / page cache, making / permanently return 404.

This extracts the /index to / normalization into normalizeResolvedPathname() and adds a guard: the normalization is skipped when normalizedSrcPage is a dynamic route, keeping the cache key as /index and avoiding the collision.

Fixes #92296

When a root-level dynamic route (e.g., [slug] with dynamicParams: true)
coexists with / and the / page has a stale ISR cache, a request to
/index is handled by [slug] but its resolvedPathname is normalized to /,
causing the ISR cache key (ssgCacheKey) to collide with the / page.
The [slug] notFound() result then overwrites the / page's cache, making
/ permanently return 404.

This extracts the /index to / normalization into
normalizeResolvedPathname() and adds a guard: the normalization is
skipped when normalizedSrcPage is a dynamic route, keeping the cache
key as /index and avoiding the collision.

Fixes vercel#92296
Copy link
Copy Markdown
Contributor

@vercel vercel Bot left a comment

Choose a reason for hiding this comment

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

Additional Suggestions:

  1. app-route.ts re-normalizes the ISR cache key (/index -> /) unconditionally, undoing the prepare() fix that preserves /index for root dynamic route handlers and re-introducing the cache-key collision with the / page.
  1. Unconditional cacheKey normalization in pages-handler.ts collapses /index back to /, re-introducing the ISR cache-key collision the PR fixes for root dynamic pages routes

Fix on Vercel

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.

GET /index with [slug] dynamic route poisons ISR cache for /, causing permanent 404

1 participant