Skip to content

fix: Don't fall through to catch-all when static child subtree doesn't match#90957

Merged
acdlite merged 1 commit intovercel:canaryfrom
acdlite:fix/optimistic-route-catchall-fallback
Mar 6, 2026
Merged

fix: Don't fall through to catch-all when static child subtree doesn't match#90957
acdlite merged 1 commit intovercel:canaryfrom
acdlite:fix/optimistic-route-catchall-fallback

Conversation

@acdlite
Copy link
Contributor

@acdlite acdlite commented Mar 6, 2026

When matching a URL against the known route trie, if a URL part matches a static child but the remaining parts don't resolve within that child's subtree, the algorithm incorrectly falls back to a dynamic catch-all sibling at the same level. This causes the catch-all to consume the already-matched static part plus the remaining parts, producing a synthetic entry for the wrong route.

For example, given routes /dashboard/settings/profile and /dashboard/[...catchall], navigating to /dashboard/settings/profile could incorrectly match the catch-all with params ["settings", "profile"] instead of the intended static route.

The fix treats the static child match as authoritative: if a real (non-placeholder) static child exists but its subtree can't resolve the remaining URL parts, bail out to server resolution rather than trying the dynamic sibling. This is safe because it just means an extra network request for routes whose subtree hasn't been fully discovered.

@nextjs-bot
Copy link
Collaborator

nextjs-bot commented Mar 6, 2026

Tests Passed

…t match

When matching a URL against the known route trie, if a URL part matches
a static child but the remaining parts don't resolve within that
child's subtree, the algorithm incorrectly falls back to a dynamic
catch-all sibling at the same level. This causes the catch-all to
consume the already-matched static part plus the remaining parts,
producing a synthetic entry for the wrong route.

For example, given routes /dashboard/settings/profile and
/dashboard/[...catchall], navigating to /dashboard/settings/profile
could incorrectly match the catch-all with params
["settings", "profile"] instead of the intended static route.

The fix treats the static child match as authoritative: if a real
(non-placeholder) static child exists but its subtree can't resolve the
remaining URL parts, bail out to server resolution rather than trying
the dynamic sibling. This is safe because it just means an extra
network request for routes whose subtree hasn't been fully discovered.
@acdlite acdlite force-pushed the fix/optimistic-route-catchall-fallback branch from fcd6656 to 592d5ab Compare March 6, 2026 04:15
@acdlite acdlite marked this pull request as ready for review March 6, 2026 04:16
@acdlite acdlite requested a review from ztanner March 6, 2026 04:16
@acdlite acdlite merged commit f27b492 into vercel:canary Mar 6, 2026
269 of 272 checks passed
sokra pushed a commit that referenced this pull request Mar 6, 2026
…t match (#90957)

When matching a URL against the known route trie, if a URL part matches
a static child but the remaining parts don't resolve within that child's
subtree, the algorithm incorrectly falls back to a dynamic catch-all
sibling at the same level. This causes the catch-all to consume the
already-matched static part plus the remaining parts, producing a
synthetic entry for the wrong route.

For example, given routes `/dashboard/settings/profile` and
`/dashboard/[...catchall]`, navigating to `/dashboard/settings/profile`
could incorrectly match the catch-all with params `["settings",
"profile"]` instead of the intended static route.

The fix treats the static child match as authoritative: if a real
(non-placeholder) static child exists but its subtree can't resolve the
remaining URL parts, bail out to server resolution rather than trying
the dynamic sibling. This is safe because it just means an extra network
request for routes whose subtree hasn't been fully discovered.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants