mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 00:09:23 +02:00
[PR #348] [MERGED] fix: layout not receiving correct params #497
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#497
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/348
Author: @james-elicx
Created: 3/8/2026
Status: ✅ Merged
Merged: 3/8/2026
Merged by: @james-elicx
Base:
main← Head:j-branch-4📝 Commits (2)
6cd7099fix: layout not receiving correct params607f979fix: layout not getting correct params on 404📊 Changes
10 files changed (+225 additions, -13 deletions)
View changed files
📝
packages/vinext/src/server/app-dev-server.ts(+18 -12)➕
tests/e2e/app-router/layout-params.spec.ts(+119 -0)📝
tests/e2e/app-router/ssr.spec.ts(+1 -1)➕
tests/fixtures/app-basic/app/blog/[slug]/layout.tsx(+31 -0)➕
tests/fixtures/app-basic/app/nextjs-compat/layout-params-notfound/[slug]/layout.tsx(+15 -0)➕
tests/fixtures/app-basic/app/nextjs-compat/layout-params-notfound/[slug]/not-found.tsx(+13 -0)➕
tests/fixtures/app-basic/app/nextjs-compat/layout-params-notfound/[slug]/page.tsx(+19 -0)➕
tests/fixtures/app-basic/app/nextjs-compat/layout-params-notfound/layout.tsx(+3 -0)➕
tests/fixtures/app-basic/app/nextjs-compat/layout-params-notfound/not-found.tsx(+3 -0)➕
tests/fixtures/app-basic/app/nextjs-compat/layout-params-notfound/page.tsx(+3 -0)📄 Description
fixes #346
fix: pass matched params to layouts in
renderHTTPAccessFallbackPage**When
notFound(),forbidden(), orunauthorized()is thrown from a page component,renderHTTPAccessFallbackPagere-renders the layout tree wrapping the fallback boundary. The layouts receive aparamsprop — but the function was readingopts?.paramswhich was never set at any call site (the callers all passed{ params }before the rename, which put the value on the wrong key). The fallback fell through toroute?.params ?? {}which is the static array of param names from the route scan, not the matched values. So every layout in the fallback tree received{}, causingawait paramsto resolve to{}and any destructuring of param keys (e.g.const { slug } = await params) to silently produceundefined— or crash withCannot destructure property 'slug' of '(intermediate value)' as it is undefinedin the SSR pass.The fix renames the option key from
paramstomatchedParamsthroughout and reads it correctly inrenderHTTPAccessFallbackPage. A second duplicate call block that was added in the layout pre-render loop (dead code after theifthat already returns) is also removed.Regression test:
layout-params-notfound/[slug]/layout.tsxalways renders and setsdata-slugfromawait params. The page callsnotFound()for invalid slugs, forcingrenderHTTPAccessFallbackPageto re-render the layout. The test assertsdata-slug="bad-slug"on the wrapper — this is only true if the real matched params were forwarded. Without the fix the attribute is empty/undefined and the SSR pass crashes.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.