Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/next/src/build/define-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,6 @@ export function getDefineEnv({
config.experimental.optimisticRouting ?? false,
'process.env.__NEXT_INSTRUMENTATION_CLIENT_ROUTER_TRANSITION_EVENTS':
config.experimental.instrumentationClientRouterTransitionEvents ?? false,
'process.env.__NEXT_APP_SHELLS': config.experimental.appShells ?? false,
'process.env.__NEXT_VARY_PARAMS': config.experimental.varyParams ?? false,
'process.env.__NEXT_EXPOSE_TESTING_API':
dev || config.experimental.exposeTestingApiInProductionBuild === true,
Expand Down
1 change: 0 additions & 1 deletion packages/next/src/build/templates/app-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,6 @@ export async function handler(
useCacheTimeout: nextConfig.experimental.useCacheTimeout,
cachedNavigations:
nextConfig.experimental.cachedNavigations ?? false,
appShells: nextConfig.experimental.appShells,
clientTraceMetadata:
nextConfig.experimental.clientTraceMetadata || ([] as any),
clientParamParsingOrigins:
Expand Down
1 change: 0 additions & 1 deletion packages/next/src/build/templates/edge-ssr-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ async function requestHandler(
serverComponentsHmrCancellation: false,
useCacheTimeout: nextConfig.experimental.useCacheTimeout,
cachedNavigations: nextConfig.experimental.cachedNavigations ?? false,
appShells: nextConfig.experimental.appShells,
clientTraceMetadata:
nextConfig.experimental.clientTraceMetadata || ([] as any),
clientParamParsingOrigins:
Expand Down
9 changes: 5 additions & 4 deletions packages/next/src/client/components/segment-cache/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2629,10 +2629,11 @@ export async function fetchSegmentPrefetchesUsingDynamicRequest(
// staleAt that corresponds to whatever payload the spawned entries get
// filled with below.
let staleAtForSpawnedEntries = staleAt
if (!process.env.__NEXT_APP_SHELLS || cacheData === null) {
// NOTE: cacheData is always set when Cached Navigations is enabled, and
// therefore when App Shells is enabled. This null check can be removed
// when those flags fully land.
if (cacheData === null) {
// No shell can be extracted without cache metadata (only present when
// Cached Navigations is enabled). For routes without a distinct App Shell
// the extraction below is a no-op anyway (`resolveShellStageData` returns
// null), so this just short-circuits that case.
serverDataThatSatisfiesSpawnedEntries = serverData
} else {
const shellStageData = await resolveShellStageData(
Expand Down
32 changes: 22 additions & 10 deletions packages/next/src/client/components/segment-cache/scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
import { matchSegment } from '../match-segments'
import {
readOrCreateRouteCacheEntry,
readRouteCacheEntry,
readOrCreateSegmentCacheEntry,
fetchRouteOnCacheMiss,
fetchSegmentsOnCacheMiss,
Expand Down Expand Up @@ -575,9 +576,24 @@ function processQueueInMicrotask() {
continue
case PrefetchTaskExitStatus.Done:
if (task.phase === PrefetchPhase.RouteTree) {
// Finished prefetching the route tree. If App Shells are enabled,
// run the Shell phase next; otherwise go straight to Speculative.
task.phase = process.env.__NEXT_APP_SHELLS
// Finished prefetching the route tree. The two-phase (Shell then
// Speculative) flow only applies to routes that have opted into
// Partial Prefetching — either globally via the `partialPrefetching`
// config or per segment (`instant`, `prefetch: 'partial'`,
// `'unstable_eager'`, or `'allow-runtime'`), all surfaced as the
// `SubtreeHasPartialPrefetching` hint on the route tree. Every other
// route skips the Shell phase and goes straight to Speculative.
//
// The route entry is fulfilled at this point (the RouteTree phase
// just completed), so its prefetch hints are available.
const route = readRouteCacheEntry(now, task.key)
const routeHasPartialPrefetching =
route !== null &&
route.status === EntryStatus.Fulfilled &&
(route.tree.prefetchHints &
PrefetchHint.SubtreeHasPartialPrefetching) !==
0
task.phase = routeHasPartialPrefetching
? PrefetchPhase.Shell
: PrefetchPhase.Speculative
heapResift(taskHeap, task)
Expand Down Expand Up @@ -2051,17 +2067,13 @@ export function subtreeHasSpeculativePrefetch(
fetchStrategy: FetchStrategy,
prefetchHints: number
): boolean {
if (!process.env.__NEXT_APP_SHELLS) {
// When App Shells is disabled, all prefetches implicitly include the
// speculative (non-shell) part of the target.
return true
}

return (
// Check if this is a "full" prefetch (<Link prefetch={true}>).
fetchStrategy === FetchStrategy.Full ||
// Check if something in this subtree is configured to be eagerly
// prefetched at the route level.
// prefetched at the route level. Segments that don't opt into Partial
// Prefetching are marked eager, so a route without any Partial Prefetching
// still speculatively prefetches everything.
(prefetchHints & PrefetchHint.SubtreeHasEagerPrefetch) !== 0
)
}
Expand Down
1 change: 0 additions & 1 deletion packages/next/src/export/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,6 @@ async function exportAppImpl(
authInterrupts: !!nextConfig.experimental.authInterrupts,
useCacheTimeout: nextConfig.experimental.useCacheTimeout,
cachedNavigations: nextConfig.experimental.cachedNavigations ?? false,
appShells: nextConfig.experimental.appShells,
maxPostponedStateSizeBytes: parseMaxPostponedStateSize(
nextConfig.experimental.maxPostponedStateSize
),
Expand Down
Loading
Loading