Skip to content

Commit b048604

Browse files
committed
1 parent 6102b28 commit b048604

221 files changed

Lines changed: 495 additions & 778 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export const unstable_instant = true
2+
3+
export default function Page() {
4+
return <div>Hello</div>
5+
}

packages/next/src/server/app-render/create-flight-router-state-from-loader-tree.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,10 @@ async function createFlightRouterStateFromLoaderTreeImpl(
9090

9191
if (instantConfig === false) {
9292
prefetchHints |= PrefetchHint.PrefetchDisabled
93-
} else if (instantConfig === true || typeof instantConfig === 'object') {
93+
} else if (
94+
instantConfig === true ||
95+
(typeof instantConfig === 'object' && instantConfig !== null)
96+
) {
9497
prefetchHints |= PrefetchHint.SubtreeHasInstant
9598
}
9699

packages/next/src/server/app-render/instant-validation/instant-config.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,13 @@ export async function isPageAllowedToBlock(tree: LoaderTree): Promise<boolean> {
4848
// the page isn't allowed to block. The config expresses a requirement for
4949
// instant UI, so we should make sure that a static shell exists.
5050
// (even if it'd use runtime prefetching for client navs)
51-
if (instantConfig !== undefined) {
52-
if (instantConfig === false) {
53-
return true
54-
} else {
55-
return false
56-
}
51+
if (instantConfig === false) {
52+
return true
53+
} else if (
54+
instantConfig === true ||
55+
(typeof instantConfig === 'object' && instantConfig !== null)
56+
) {
57+
return false
5758
}
5859

5960
const { parallelRoutes } = parseLoaderTree(tree)
@@ -157,8 +158,8 @@ export const resolveInstantConfigSamplesForPage = async (
157158

158159
let samples: InstantSample[] | null = null
159160
if (
160-
instantConfig !== undefined &&
161161
typeof instantConfig === 'object' &&
162+
instantConfig !== null &&
162163
instantConfig.samples
163164
) {
164165
samples = instantConfig.samples

packages/next/src/server/app-render/instant-validation/instant-validation.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,10 @@ export async function createCombinedPayloadAtDepth(
11531153
(layoutOrPageMod as AppSegmentConfig).unstable_instant ?? null
11541154
prefetchConfig =
11551155
(layoutOrPageMod as AppSegmentConfig).unstable_prefetch ?? null
1156-
if (instantConfig && typeof instantConfig === 'object') {
1156+
if (
1157+
instantConfig === true ||
1158+
(typeof instantConfig === 'object' && instantConfig !== null)
1159+
) {
11571160
const rawFactory: unknown = (layoutOrPageMod as any)
11581161
.__debugCreateInstantConfigStack
11591162
localCreateInstantStack =
@@ -1241,7 +1244,10 @@ export async function createCombinedPayloadAtDepth(
12411244
requiresInstantUI = false
12421245
createInstantStack = null
12431246
configDepth = -1
1244-
} else if (instantConfig === true || typeof instantConfig === 'object') {
1247+
} else if (
1248+
instantConfig === true ||
1249+
(typeof instantConfig === 'object' && instantConfig !== null)
1250+
) {
12451251
requiresInstantUI = true
12461252
createInstantStack = localCreateInstantStack
12471253
configDepth = segmentDepth

test/development/app-dir/cache-components-dev-warmup/fixtures/with-prefetch-config/app/apis/[param]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { CachedData } from '../../data-fetching'
33
import { connection } from 'next/server'
44
import { Suspense } from 'react'
55

6-
export const unstable_instant = { prefetch: 'runtime', samples: [{}] }
6+
export const unstable_instant = true
77
export const unstable_prefetch = 'runtime'
88

99
const CACHE_KEY = __dirname + '/__PAGE__'

test/development/app-dir/cache-components-dev-warmup/fixtures/with-prefetch-config/app/private-cache/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Suspense } from 'react'
22
import { UncachedFetch, CachedData } from '../data-fetching'
33
import { PrivateCachedData } from './data-fetching'
44

5-
export const unstable_instant = { prefetch: 'runtime', samples: [{}] }
5+
export const unstable_instant = true
66
export const unstable_prefetch = 'runtime'
77

88
const CACHE_KEY = '/private-cache/__LAYOUT__'

test/development/app-dir/cache-components-dev-warmup/fixtures/with-prefetch-config/app/short-lived-cache/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Suspense } from 'react'
22
import { UncachedFetch, CachedData } from '../data-fetching'
33
import { ShortLivedCache } from './data-fetching'
44

5-
export const unstable_instant = { prefetch: 'runtime', samples: [{}] }
5+
export const unstable_instant = true
66
export const unstable_prefetch = 'runtime'
77

88
const CACHE_KEY = __dirname + '/__LAYOUT__'

test/development/app-dir/cache-components-dev-warmup/fixtures/with-prefetch-config/app/simple/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Suspense } from 'react'
22
import { UncachedFetch, CachedFetch, CachedData } from '../data-fetching'
33

4-
export const unstable_instant = { prefetch: 'runtime', samples: [{}] }
4+
export const unstable_instant = true
55
export const unstable_prefetch = 'runtime'
66

77
const CACHE_KEY = __dirname + '/__LAYOUT__'

test/development/app-dir/cache-components-dev-warmup/fixtures/with-prefetch-config/app/successive-caches/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const unstable_instant = { prefetch: 'runtime', samples: [{}] }
1+
export const unstable_instant = true
22
export const unstable_prefetch = 'runtime'
33

44
export default async function Page() {

test/development/app-dir/cache-components-dev-warmup/fixtures/with-prefetch-config/app/sync-io/runtime/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Suspense } from 'react'
22
import { CachedData, getCachedData } from '../../data-fetching'
33
import { cookies } from 'next/headers'
44

5-
export const unstable_instant = { prefetch: 'runtime', samples: [{}] }
5+
export const unstable_instant = true
66
export const unstable_prefetch = 'runtime'
77

88
const CACHE_KEY = __dirname + '/__PAGE__'

0 commit comments

Comments
 (0)