Unverified Commit d698d658 authored by Josh Story's avatar Josh Story Committed by GitHub

Remove partialFallbacks config flag (#93859)

Flag is already defaulted true. Removes option to disable
parent 4e75a9c3
......@@ -1543,10 +1543,7 @@ export async function handleBuildComplete({
(item) => item.page === dynamicRoute
)?.routeKeys || {}
const allowQuery = Object.values(routeKeys)
const partialFallbacksEnabled =
config.experimental.partialFallbacks === true
const partialFallback =
partialFallbacksEnabled &&
isAppPage &&
remainingPrerenderableParams !== undefined &&
remainingPrerenderableParams.length > 0 &&
......@@ -1573,7 +1570,7 @@ export async function handleBuildComplete({
// RSC shell.
else if (meta.postponed) {
// If there's postponed fallback content, we usually collapse to a shared shell (`[]`).
// For opt-in partial fallbacks in cache components, keep only the
// For partial fallbacks in cache components, keep only the
// params that can still complete this shell.
const remainingPrerenderableQueryKeys = new Set(
(remainingPrerenderableParams ?? []).map(
......
......@@ -2109,8 +2109,6 @@ export default async function build(
defaultLocale: config.i18n?.defaultLocale,
nextConfigOutput: config.output,
pprConfig: config.experimental.ppr,
partialFallbacksEnabled:
config.experimental.partialFallbacks === true,
cacheLifeProfiles: config.cacheLife,
buildId,
deploymentId: config.deploymentId,
......@@ -2344,8 +2342,6 @@ export default async function build(
cacheMaxMemorySize: config.cacheMaxMemorySize,
nextConfigOutput: config.output,
pprConfig: config.experimental.ppr,
partialFallbacksEnabled:
config.experimental.partialFallbacks === true,
cacheLifeProfiles: config.cacheLife,
buildId,
deploymentId: config.deploymentId,
......
......@@ -44,7 +44,7 @@ describe('assignStaticShellMetadata', () => {
},
]
assignStaticShellMetadata(prerenderedRoutes, [], true)
assignStaticShellMetadata(prerenderedRoutes, [])
expect(prerenderedRoutes[0].throwOnEmptyStaticShell).toBe(true)
})
......@@ -76,7 +76,7 @@ describe('assignStaticShellMetadata', () => {
},
]
assignStaticShellMetadata(prerenderedRoutes, pathnameSegments('id'), true)
assignStaticShellMetadata(prerenderedRoutes, pathnameSegments('id'))
expect(prerenderedRoutes[0].throwOnEmptyStaticShell).toBe(false)
expect(prerenderedRoutes[1].throwOnEmptyStaticShell).toBe(true)
......@@ -150,11 +150,7 @@ describe('assignStaticShellMetadata', () => {
},
]
assignStaticShellMetadata(
prerenderedRoutes,
pathnameSegments('id', 'name'),
true
)
assignStaticShellMetadata(prerenderedRoutes, pathnameSegments('id', 'name'))
expect(prerenderedRoutes[0].throwOnEmptyStaticShell).toBe(false)
expect(prerenderedRoutes[1].throwOnEmptyStaticShell).toBe(false)
......@@ -210,8 +206,7 @@ describe('assignStaticShellMetadata', () => {
assignStaticShellMetadata(
prerenderedRoutes,
pathnameSegments('id', ['name', true], 'extra'),
true
pathnameSegments('id', ['name', true], 'extra')
)
expect(prerenderedRoutes[0].throwOnEmptyStaticShell).toBe(false)
......@@ -234,45 +229,10 @@ describe('assignStaticShellMetadata', () => {
it('should handle empty input', () => {
const prerenderedRoutes: PrerenderedRoute[] = []
assignStaticShellMetadata(prerenderedRoutes, [], true)
assignStaticShellMetadata(prerenderedRoutes, [])
expect(prerenderedRoutes).toEqual([])
})
it('should skip remaining prerenderable params when partial fallbacks are disabled', () => {
const prerenderedRoutes: PrerenderedRoute[] = [
{
params: {},
pathname: '/[id]',
encodedPathname: '/[id]',
fallbackRouteParams: [
{
paramName: 'id',
paramType: 'dynamic',
},
],
fallbackMode: FallbackMode.NOT_FOUND,
fallbackRootParams: [],
throwOnEmptyStaticShell: true,
},
{
params: { id: '1' },
pathname: '/1',
encodedPathname: '/1',
fallbackRouteParams: [],
fallbackMode: FallbackMode.NOT_FOUND,
fallbackRootParams: [],
throwOnEmptyStaticShell: true,
},
]
assignStaticShellMetadata(prerenderedRoutes, pathnameSegments('id'), false)
expect(prerenderedRoutes[0].throwOnEmptyStaticShell).toBe(false)
expect(prerenderedRoutes[1].throwOnEmptyStaticShell).toBe(true)
expect(prerenderedRoutes[0].remainingPrerenderableParams).toBeUndefined()
expect(prerenderedRoutes[1].remainingPrerenderableParams).toBeUndefined()
})
it('should handle blog/[slug] not throwing when concrete routes exist (from docs example)', () => {
const prerenderedRoutes: PrerenderedRoute[] = [
{
......@@ -309,7 +269,7 @@ describe('assignStaticShellMetadata', () => {
},
]
assignStaticShellMetadata(prerenderedRoutes, pathnameSegments('slug'), true)
assignStaticShellMetadata(prerenderedRoutes, pathnameSegments('slug'))
expect(prerenderedRoutes[0].throwOnEmptyStaticShell).toBe(false) // Should not throw - has concrete children
expect(prerenderedRoutes[1].throwOnEmptyStaticShell).toBe(true) // Should throw - concrete route
......@@ -361,11 +321,7 @@ describe('assignStaticShellMetadata', () => {
},
]
assignStaticShellMetadata(
prerenderedRoutes,
pathnameSegments('id', 'slug'),
true
)
assignStaticShellMetadata(prerenderedRoutes, pathnameSegments('id', 'slug'))
expect(prerenderedRoutes[0].throwOnEmptyStaticShell).toBe(false) // Should not throw - has children
expect(prerenderedRoutes[1].throwOnEmptyStaticShell).toBe(false) // Should not throw - has children
......@@ -445,8 +401,7 @@ describe('assignStaticShellMetadata', () => {
assignStaticShellMetadata(
prerenderedRoutes,
pathnameSegments('category', 'subcategory', 'item'),
true
pathnameSegments('category', 'subcategory', 'item')
)
// All except the last one should not throw on empty static shell
......@@ -485,8 +440,7 @@ describe('assignStaticShellMetadata', () => {
assignStaticShellMetadata(
prerenderedRoutes,
pathnameSegments('locale', 'segments'),
true
pathnameSegments('locale', 'segments')
)
// The route with more fallback params should not throw on empty static shell
......@@ -532,8 +486,7 @@ describe('assignStaticShellMetadata', () => {
assignStaticShellMetadata(
prerenderedRoutes,
pathnameSegments(['one', true], 'two'),
true
pathnameSegments(['one', true], 'two')
)
expect(prerenderedRoutes[0].remainingPrerenderableParams).toEqual([
......@@ -591,8 +544,7 @@ describe('assignStaticShellMetadata', () => {
assignStaticShellMetadata(
prerenderedRoutes,
pathnameSegments(['one', true], 'two', ['three', true]),
true
pathnameSegments(['one', true], 'two', ['three', true])
)
expect(prerenderedRoutes[0].remainingPrerenderableParams).toEqual([
......
......@@ -433,8 +433,7 @@ export function assignStaticShellMetadata(
pathnameSegments: ReadonlyArray<{
readonly paramName: string
readonly hasGenerateStaticParams: boolean
}>,
computeRemainingPrerenderableParams: boolean
}>
): void {
// If there are no routes to process, exit early.
if (prerenderedRoutes.length === 0) {
......@@ -554,11 +553,7 @@ export function assignStaticShellMetadata(
route.throwOnEmptyStaticShell = true // Should throw on empty static shell.
}
if (
computeRemainingPrerenderableParams &&
route.fallbackRouteParams &&
route.fallbackRouteParams.length > 0
) {
if (route.fallbackRouteParams && route.fallbackRouteParams.length > 0) {
const fallbackRouteParamsByName = new Map(
route.fallbackRouteParams.map((param) => [param.paramName, param])
)
......@@ -795,7 +790,6 @@ export async function buildAppStaticPaths({
nextConfigOutput,
ComponentMod,
isRoutePPREnabled = false,
partialFallbacksEnabled = false,
buildId,
deploymentId,
rootParamKeys,
......@@ -821,7 +815,6 @@ export async function buildAppStaticPaths({
nextConfigOutput: 'standalone' | 'export' | undefined
ComponentMod: AppPageModule | AppRouteModule
isRoutePPREnabled: boolean
partialFallbacksEnabled?: boolean
buildId: string
deploymentId: string
rootParamKeys: readonly string[]
......@@ -1125,11 +1118,7 @@ export async function buildAppStaticPaths({
// Now we have to set the throwOnEmptyStaticShell for each of the routes.
if (prerenderedRoutes && cacheComponents) {
assignStaticShellMetadata(
prerenderedRoutes,
prerenderablePathSegments,
partialFallbacksEnabled
)
assignStaticShellMetadata(prerenderedRoutes, prerenderablePathSegments)
}
return { fallbackMode, prerenderedRoutes }
......
......@@ -597,7 +597,6 @@ export async function handler(
: null
if (
nextConfig.experimental.partialFallbacks === true &&
fallbackPathname &&
prerenderInfo?.fallbackRouteParams?.length &&
!hasUnresolvedRootFallbackParams
......@@ -682,7 +681,6 @@ export async function handler(
routerServerContext?.isWrappedByNextServer
)
const remainingFallbackRouteParams =
nextConfig.experimental.partialFallbacks === true &&
remainingPrerenderableParams.length > 0
? (prerenderInfo?.fallbackRouteParams?.filter(
(param) =>
......@@ -1052,7 +1050,6 @@ export async function handler(
}
if (
nextConfig.experimental.partialFallbacks === true &&
prerenderInfo?.fallback === null &&
!hasOmittedConcreteFallbackParam &&
!hasUnresolvedRootFallbackParams &&
......@@ -1214,7 +1211,6 @@ export async function handler(
// Match the build-time contract: only fallback shells that can
// still be completed with prerenderable params should upgrade.
remainingPrerenderableParams.length > 0 &&
nextConfig.experimental.partialFallbacks === true &&
ssgCacheKey &&
incrementalCache &&
!isOnDemandRevalidate &&
......
......@@ -694,7 +694,6 @@ export async function isPageStatic({
cacheHandlers,
cacheLifeProfiles,
pprConfig,
partialFallbacksEnabled,
buildId,
deploymentId,
clientAssetToken,
......@@ -725,7 +724,6 @@ export async function isPageStatic({
}
nextConfigOutput: 'standalone' | 'export' | undefined
pprConfig: ExperimentalPPRConfig | undefined
partialFallbacksEnabled: boolean
buildId: string
deploymentId: string
clientAssetToken: string
......@@ -892,7 +890,6 @@ export async function isPageStatic({
ComponentMod,
nextConfigOutput,
isRoutePPREnabled,
partialFallbacksEnabled,
buildId,
deploymentId,
rootParamKeys,
......
......@@ -221,7 +221,6 @@ export const experimentalSchema = {
caseSensitiveRoutes: z.boolean().optional(),
clientParamParsingOrigins: z.array(z.string()).optional(),
cachedNavigations: z.boolean().optional(),
partialFallbacks: z.boolean().optional(),
dynamicOnHover: z.boolean().optional(),
useOffline: z.boolean().optional(),
optimisticRouting: z.boolean().optional(),
......
......@@ -433,11 +433,6 @@ export interface ExperimentalConfig {
*/
clientParamParsingOrigins?: string[]
cachedNavigations?: boolean
/**
* Enables partial fallback shells for cache-components routes while the
* feature stabilizes.
*/
partialFallbacks?: boolean
dynamicOnHover?: boolean
useOffline?: boolean
optimisticRouting?: boolean
......@@ -1921,7 +1916,6 @@ export const defaultConfig = Object.freeze({
caseSensitiveRoutes: false,
clientParamParsingOrigins: undefined,
cachedNavigations: false,
partialFallbacks: true,
dynamicOnHover: false,
useOffline: false,
varyParams: false,
......@@ -2103,7 +2097,6 @@ export interface NextConfigRuntime {
| 'runtimeServerDeploymentId'
| 'maxPostponedStateSize'
| 'cachedNavigations'
| 'partialFallbacks'
| 'exposeTestingApiInProductionBuild'
| 'supportsImmutableAssets'
| 'useNodeStreams'
......@@ -2172,7 +2165,6 @@ export function getNextConfigRuntime(
runtimeServerDeploymentId: ex.runtimeServerDeploymentId,
maxPostponedStateSize: ex.maxPostponedStateSize,
cachedNavigations: ex.cachedNavigations,
partialFallbacks: ex.partialFallbacks,
exposeTestingApiInProductionBuild: ex.exposeTestingApiInProductionBuild,
supportsImmutableAssets: ex.supportsImmutableAssets,
useNodeStreams: ex.useNodeStreams,
......
......@@ -807,8 +807,6 @@ export default class DevServer extends Server {
pathname,
config: {
pprConfig: this.nextConfig.experimental.ppr,
partialFallbacks:
this.nextConfig.experimental.partialFallbacks === true,
configFileName,
cacheComponents: Boolean(this.nextConfig.cacheComponents),
},
......
......@@ -30,7 +30,6 @@ import { parseNormalizedAppRoute } from '../../shared/lib/router/routes/app'
type RuntimeConfig = {
pprConfig: ExperimentalPPRConfig | undefined
partialFallbacks: boolean
configFileName: string
cacheComponents: boolean
}
......@@ -154,7 +153,6 @@ export async function loadStaticPaths({
ComponentMod: components.ComponentMod,
nextConfigOutput,
isRoutePPREnabled,
partialFallbacksEnabled: config.partialFallbacks,
buildId,
deploymentId,
authInterrupts,
......
import type { ReactNode } from 'react'
export default async function RootLayout({
children,
}: {
children: ReactNode
}) {
return (
<html>
<body>{children}</body>
</html>
)
}
export default function Loading() {
return (
<div id="two-fallback" data-fallback>
loading two...
</div>
)
}
export default async function Page({
params,
}: {
params: Promise<{ one: string; two: string }>
}) {
const { two } = await params
return <div id="two">{two}</div>
}
import { Suspense, type ReactNode } from 'react'
type LayoutProps = {
children: ReactNode
params: Promise<{ one: string }>
}
export function generateStaticParams() {
return [{ one: 'b' }]
}
async function LayoutImpl({ children, params }: LayoutProps) {
const { one } = await params
return (
<div>
<div id="one">{one}</div>
{children}
</div>
)
}
export default async function LayoutWrapper(props: LayoutProps) {
return (
<Suspense
fallback={
<div id="one-fallback" data-fallback>
loading one...
</div>
}
>
<LayoutImpl {...props} />
</Suspense>
)
}
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
cacheComponents: true,
experimental: {
partialFallbacks: false,
},
}
module.exports = nextConfig
......@@ -168,59 +168,3 @@ describe('partial-fallback-shell-upgrade', () => {
)
})
})
describe('partial-fallback-shell-upgrade when disabled', () => {
const { next, isNextDev } = nextTestSetup({
files: path.join(__dirname, 'fixtures', 'disabled'),
// The latest changes to support this behavior on deployed infra are available in the adapter,
// and are not being backported to the CLI
skipDeployment: !isAdapterTest,
})
if (isNextDev) {
it('skipped in dev', () => {})
return
}
const fetchSplitHTML = createSplitHTMLFetcher(next)
it('should keep serving the generic shell when partialFallbacks is disabled', async () => {
const firstResult = await fetchSplitHTML('/prefix/c/foo')
expect(firstResult.response.status).toBe(200)
expect(firstResult.static$('#one').length).toBe(0)
expect(firstResult.static$('#one-fallback').text()).toBe('loading one...')
expect(firstResult.static$('#two-fallback').length).toBe(0)
expect(firstResult.static$('#two').length).toBe(0)
expect(firstResult.dynamicPart).toContain('<div id="one">c</div>')
expect(firstResult.dynamicPart).toContain('<div id="two">foo</div>')
const start = Date.now()
await retry(
async () => {
const secondResult = await fetchSplitHTML('/prefix/c/bar')
expect(secondResult.response.status).toBe(200)
expect(secondResult.static$('#one').length).toBe(0)
expect(secondResult.static$('#one-fallback').text()).toBe(
'loading one...'
)
expect(secondResult.static$('#two-fallback').length).toBe(0)
expect(secondResult.static$('#two').length).toBe(0)
expect(secondResult.dynamicPart).toContain('<div id="one">c</div>')
expect(secondResult.dynamicPart).toContain('<div id="two">bar</div>')
expect(secondResult.dynamicPart).not.toContain(
'<div id="two">foo</div>'
)
if (Date.now() - start < 5000) {
throw new Error('continue polling generic shell')
}
},
6000,
500,
'generic shell should remain unupgraded when partialFallbacks is disabled'
)
})
})
......@@ -5920,8 +5920,7 @@
"partial-fallback-shell-upgrade should not keep upgrading once only fully dynamic params remain",
"partial-fallback-shell-upgrade should not upgrade a route shell when no params were prerendered",
"partial-fallback-shell-upgrade should upgrade a generic shell into the most specific prerendered shell",
"partial-fallback-shell-upgrade should upgrade the fallback shell to a route shell",
"partial-fallback-shell-upgrade when disabled should keep serving the generic shell when partialFallbacks is disabled"
"partial-fallback-shell-upgrade should upgrade the fallback shell to a route shell"
],
"failed": [],
"pending": [],
......@@ -8630,10 +8630,7 @@
"runtimeError": false
},
"test/e2e/app-dir/partial-fallback-shell-upgrade/partial-fallback-shell-upgrade.test.ts": {
"passed": [
"partial-fallback-shell-upgrade skipped in dev",
"partial-fallback-shell-upgrade when disabled skipped in dev"
],
"passed": ["partial-fallback-shell-upgrade skipped in dev"],
"failed": [],
"pending": [],
"flakey": [],
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment