Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
2f3e930d
Commit
2f3e930d
authored
Apr 03, 2026
by
Jimmy Lai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: trigger not-found on client-side nav when children slot uses built-in default (#79352)
parent
4a2e8e7f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
2 deletions
+41
-2
ppr-navigations.ts
...t/src/client/components/router-reducer/ppr-navigations.ts
+10
-1
create-flight-router-state-from-loader-tree.ts
...app-render/create-flight-router-state-from-loader-tree.ts
+25
-1
app-router-types.ts
packages/next/src/shared/lib/app-router-types.ts
+6
-0
No files found.
packages/next/src/client/components/router-reducer/ppr-navigations.ts
View file @
2f3e930d
...
...
@@ -459,7 +459,16 @@ function updateCacheNodeOnNavigation(
// was stashed in the history entry as-is.
freshness
!==
FreshnessPolicy
.
HistoryTraversal
&&
newSegmentChild
===
DEFAULT_SEGMENT_KEY
&&
oldSegmentChild
!==
DEFAULT_SEGMENT_KEY
oldSegmentChild
!==
DEFAULT_SEGMENT_KEY
&&
// Do not reuse the previously active segment if this __DEFAULT__
// segment uses the built-in default component that calls notFound().
// The built-in default means there is no matching page or
// user-provided default.tsx for this slot. Reusing old content would
// hide the 404 that should be triggered by the built-in default.
!
(
newRouteTreeChild
.
prefetchHints
&
PrefetchHint
.
IsBuiltinNotFoundDefault
)
)
{
// This is a "default" segment. These are never sent by the server during
// a soft navigation; instead, the client reuses whatever segment was
...
...
packages/next/src/server/app-render/create-flight-router-state-from-loader-tree.ts
View file @
2f3e930d
...
...
@@ -5,8 +5,12 @@ import {
type
PrefetchHints
,
}
from
'../../shared/lib/app-router-types'
import
type
{
GetDynamicParamFromSegment
}
from
'./app-render'
import
{
addSearchParamsIfPageSegment
}
from
'../../shared/lib/segment'
import
{
DEFAULT_SEGMENT_KEY
,
addSearchParamsIfPageSegment
,
}
from
'../../shared/lib/segment'
import
type
{
AppSegmentConfig
}
from
'../../build/segment-config/app/app-segment-config'
import
{
PARALLEL_ROUTE_DEFAULT_PATH
}
from
'../../client/components/builtin/default'
async
function
createFlightRouterStateFromLoaderTreeImpl
(
loaderTree
:
LoaderTree
,
...
...
@@ -94,6 +98,26 @@ async function createFlightRouterStateFromLoaderTreeImpl(
prefetchHints
|=
PrefetchHint
.
SegmentHasLoadingBoundary
}
// Check if this __DEFAULT__ segment uses the built-in default component
// that calls notFound(). This tells the client router not to reuse the
// previous page content when navigating to a URL with no matching page.
// The path comparison uses endsWith because the loader tree stores
// absolute filesystem paths while PARALLEL_ROUTE_DEFAULT_PATH is a
// package-relative path (e.g., "next/dist/client/components/builtin/default.js").
if
(
segment
===
DEFAULT_SEGMENT_KEY
)
{
const
{
defaultPage
}
=
loaderTree
[
2
]
if
(
defaultPage
!==
undefined
&&
typeof
defaultPage
[
1
]
===
'string'
&&
defaultPage
[
1
].
endsWith
(
// Strip the leading "next/" from the constant to match absolute paths.
PARALLEL_ROUTE_DEFAULT_PATH
.
slice
(
'next/'
.
length
)
)
)
{
prefetchHints
|=
PrefetchHint
.
IsBuiltinNotFoundDefault
}
}
const
children
:
FlightRouterState
[
1
]
=
{}
for
(
const
parallelRouteKey
in
parallelRoutes
)
{
// Look up the child hint node by parallel route key, traversing the
...
...
packages/next/src/shared/lib/app-router-types.ts
View file @
2f3e930d
...
...
@@ -209,6 +209,12 @@ export const enum PrefetchHint {
// (HasRuntimePrefetch). Propagates upward so the root reflects the
// entire subtree.
SubtreeHasRuntimePrefetch
=
0b100000000000
,
// This __DEFAULT__ segment uses the built-in default component that
// calls notFound(). Set so the client can distinguish between a
// user-provided default.tsx (where old content should be reused during
// navigation) and the built-in not-found default (where a 404 should
// be shown).
IsBuiltinNotFoundDefault
=
0b1000000000000
,
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment