Unverified Commit 59f7ca85 authored by Zack Tanner's avatar Zack Tanner Committed by GitHub

remove additional static prefetch code (#59313)

This is a continuation from https://github.com/vercel/next.js/pull/58783
to remove the remaining code related to static prefetching.
parent f431600c
...@@ -41,7 +41,6 @@ export interface StaticGenerationStore { ...@@ -41,7 +41,6 @@ export interface StaticGenerationStore {
dynamicUsageDescription?: string dynamicUsageDescription?: string
dynamicUsageStack?: string dynamicUsageStack?: string
dynamicUsageErr?: DynamicServerError dynamicUsageErr?: DynamicServerError
staticPrefetchBailout?: boolean
nextFetchId?: number nextFetchId?: number
pathWasRevalidated?: boolean pathWasRevalidated?: boolean
......
...@@ -53,12 +53,6 @@ export const staticGenerationBailout: StaticGenerationBailout = ( ...@@ -53,12 +53,6 @@ export const staticGenerationBailout: StaticGenerationBailout = (
// to 0. // to 0.
staticGenerationStore.revalidate = 0 staticGenerationStore.revalidate = 0
if (!dynamic) {
// we can statically prefetch pages that opt into dynamic,
// but not things like headers/cookies
staticGenerationStore.staticPrefetchBailout = true
}
if (staticGenerationStore.isStaticGeneration) { if (staticGenerationStore.isStaticGeneration) {
const err = new DynamicServerError(message) const err = new DynamicServerError(message)
staticGenerationStore.dynamicUsageDescription = reason staticGenerationStore.dynamicUsageDescription = reason
......
...@@ -2314,30 +2314,6 @@ export default abstract class Server<ServerOptions extends Options = Options> { ...@@ -2314,30 +2314,6 @@ export default abstract class Server<ServerOptions extends Options = Options> {
{ page: pathname, params: opts.params, query, renderOpts } { page: pathname, params: opts.params, query, renderOpts }
) )
} else if (isAppPageRouteModule(routeModule)) { } else if (isAppPageRouteModule(routeModule)) {
// TODO: Re-enable once static prefetches re-land
// if (
// !opts.experimental.ppr &&
// isPrefetchRSCRequest &&
// process.env.NODE_ENV === 'production' &&
// !this.minimalMode
// ) {
// try {
// const prefetchRsc = await this.getPrefetchRsc(resolvedUrlPathname)
// if (prefetchRsc) {
// res.setHeader(
// 'cache-control',
// 'private, no-cache, no-store, max-age=0, must-revalidate'
// )
// res.setHeader('content-type', RSC_CONTENT_TYPE_HEADER)
// res.body(prefetchRsc).send()
// return null
// }
// } catch {
// // We fallback to invoking the function if prefetch data is not
// // available.
// }
// }
const module = components.routeModule as AppPageRouteModule const module = components.routeModule as AppPageRouteModule
// Due to the way we pass data by mutating `renderOpts`, we can't extend the // Due to the way we pass data by mutating `renderOpts`, we can't extend the
......
...@@ -302,24 +302,6 @@ createNextDescribe( ...@@ -302,24 +302,6 @@ createNextDescribe(
}) })
describe('dynamic rendering', () => { describe('dynamic rendering', () => {
async function hasStaticPrefetch(filePath: string): Promise<boolean> {
try {
await next.readFile(`.next/server/app${filePath}`)
return true
} catch {
return false
}
}
it('should not generate a static prefetch for layouts that use cookies/headers', async () => {
expect(
await hasStaticPrefetch('/prefetch-dynamic-usage/foo.prefetch.rsc')
).toBe(false)
expect(
await hasStaticPrefetch('/prefetch-dynamic-usage/bar.prefetch.rsc')
).toBe(false)
})
describe.each(['/force-dynamic', '/revalidate-0'])('%s', (basePath) => { describe.each(['/force-dynamic', '/revalidate-0'])('%s', (basePath) => {
it('should not re-render layout when navigating between sub-pages', async () => { it('should not re-render layout when navigating between sub-pages', async () => {
const logStartIndex = next.cliOutput.length const logStartIndex = next.cliOutput.length
......
...@@ -507,7 +507,6 @@ createNextDescribe( ...@@ -507,7 +507,6 @@ createNextDescribe(
'ssg-draft-mode.rsc', 'ssg-draft-mode.rsc',
'ssr-forced/page.js', 'ssr-forced/page.js',
'articles/works.rsc', 'articles/works.rsc',
// 'custom.prefetch.rsc',
'force-cache/page.js', 'force-cache/page.js',
'ssg-draft-mode.html', 'ssg-draft-mode.html',
'articles/works.html', 'articles/works.html',
...@@ -526,7 +525,6 @@ createNextDescribe( ...@@ -526,7 +525,6 @@ createNextDescribe(
'force-static/first.html', 'force-static/first.html',
'force-static/second.rsc', 'force-static/second.rsc',
'ssg-draft-mode/test.rsc', 'ssg-draft-mode/test.rsc',
// 'ssr-forced.prefetch.rsc',
'isr-error-handling.html', 'isr-error-handling.html',
'articles/[slug]/page.js', 'articles/[slug]/page.js',
'no-store/static/page.js', 'no-store/static/page.js',
...@@ -537,15 +535,11 @@ createNextDescribe( ...@@ -537,15 +535,11 @@ createNextDescribe(
'no-store/dynamic/page.js', 'no-store/dynamic/page.js',
'blog/seb/second-post.html', 'blog/seb/second-post.html',
'ssg-draft-mode/test-2.rsc', 'ssg-draft-mode/test-2.rsc',
// 'response-url.prefetch.rsc',
'blog/styfle/first-post.rsc', 'blog/styfle/first-post.rsc',
// 'default-cache.prefetch.rsc',
'dynamic-error/[id]/page.js', 'dynamic-error/[id]/page.js',
'ssg-draft-mode/test-2.html', 'ssg-draft-mode/test-2.html',
'blog/styfle/first-post.html', 'blog/styfle/first-post.html',
'blog/styfle/second-post.rsc', 'blog/styfle/second-post.rsc',
// 'fetch-no-cache.prefetch.rsc',
// 'force-no-store.prefetch.rsc',
'force-static/[slug]/page.js', 'force-static/[slug]/page.js',
'hooks/use-pathname/slug.rsc', 'hooks/use-pathname/slug.rsc',
'hooks/use-search-params.rsc', 'hooks/use-search-params.rsc',
...@@ -571,12 +565,10 @@ createNextDescribe( ...@@ -571,12 +565,10 @@ createNextDescribe(
'react-fetch-deduping-node/page.js', 'react-fetch-deduping-node/page.js',
'variable-revalidate/encoding.html', 'variable-revalidate/encoding.html',
'variable-revalidate/cookie/page.js', 'variable-revalidate/cookie/page.js',
// 'gen-params-dynamic/one.prefetch.rsc',
'ssg-draft-mode/[[...route]]/page.js', 'ssg-draft-mode/[[...route]]/page.js',
'variable-revalidate/post-method.rsc', 'variable-revalidate/post-method.rsc',
'stale-cache-serving/app-page/page.js', 'stale-cache-serving/app-page/page.js',
'dynamic-no-gen-params/[slug]/page.js', 'dynamic-no-gen-params/[slug]/page.js',
// 'ssr-auto/cache-no-store.prefetch.rsc',
'static-to-dynamic-error/[id]/page.js', 'static-to-dynamic-error/[id]/page.js',
'variable-revalidate/encoding/page.js', 'variable-revalidate/encoding/page.js',
'variable-revalidate/no-store/page.js', 'variable-revalidate/no-store/page.js',
...@@ -590,7 +582,6 @@ createNextDescribe( ...@@ -590,7 +582,6 @@ createNextDescribe(
'variable-revalidate/revalidate-3.html', 'variable-revalidate/revalidate-3.html',
'force-dynamic-prerender/[slug]/page.js', 'force-dynamic-prerender/[slug]/page.js',
'gen-params-dynamic-revalidate/one.html', 'gen-params-dynamic-revalidate/one.html',
// 'react-fetch-deduping-node.prefetch.rsc',
'ssr-auto/fetch-revalidate-zero/page.js', 'ssr-auto/fetch-revalidate-zero/page.js',
'variable-revalidate/authorization.html', 'variable-revalidate/authorization.html',
'_not-found_client-reference-manifest.js', '_not-found_client-reference-manifest.js',
...@@ -603,8 +594,6 @@ createNextDescribe( ...@@ -603,8 +594,6 @@ createNextDescribe(
'variable-revalidate/headers-instance.rsc', 'variable-revalidate/headers-instance.rsc',
'variable-revalidate/revalidate-3/page.js', 'variable-revalidate/revalidate-3/page.js',
'stale-cache-serving-edge/app-page/page.js', 'stale-cache-serving-edge/app-page/page.js',
// 'stale-cache-serving/app-page.prefetch.rsc',
// 'force-dynamic-catch-all/slug.prefetch.rsc',
'hooks/use-search-params/force-static.html', 'hooks/use-search-params/force-static.html',
'hooks/use-search-params/with-suspense.rsc', 'hooks/use-search-params/with-suspense.rsc',
'route-handler/revalidate-360-isr/route.js', 'route-handler/revalidate-360-isr/route.js',
...@@ -612,13 +601,11 @@ createNextDescribe( ...@@ -612,13 +601,11 @@ createNextDescribe(
'variable-revalidate-edge/no-store/page.js', 'variable-revalidate-edge/no-store/page.js',
'variable-revalidate/authorization/page.js', 'variable-revalidate/authorization/page.js',
'variable-revalidate/headers-instance.html', 'variable-revalidate/headers-instance.html',
// 'variable-revalidate/no-store.prefetch.rsc',
'stale-cache-serving/route-handler/route.js', 'stale-cache-serving/route-handler/route.js',
'hooks/use-search-params/with-suspense.html', 'hooks/use-search-params/with-suspense.html',
'route-handler-edge/revalidate-360/route.js', 'route-handler-edge/revalidate-360/route.js',
'variable-revalidate/revalidate-360-isr.rsc', 'variable-revalidate/revalidate-360-isr.rsc',
'variable-revalidate/revalidate-360/page.js', 'variable-revalidate/revalidate-360/page.js',
// 'ssr-auto/fetch-revalidate-zero.prefetch.rsc',
'static-to-dynamic-error-forced/[id]/page.js', 'static-to-dynamic-error-forced/[id]/page.js',
'variable-config-revalidate/revalidate-3.rsc', 'variable-config-revalidate/revalidate-3.rsc',
'variable-revalidate/revalidate-360-isr.html', 'variable-revalidate/revalidate-360-isr.html',
...@@ -629,7 +616,6 @@ createNextDescribe( ...@@ -629,7 +616,6 @@ createNextDescribe(
'variable-config-revalidate/revalidate-3.html', 'variable-config-revalidate/revalidate-3.html',
'variable-revalidate-edge/post-method/page.js', 'variable-revalidate-edge/post-method/page.js',
'variable-revalidate/headers-instance/page.js', 'variable-revalidate/headers-instance/page.js',
// 'variable-revalidate/status-code.prefetch.rsc',
'force-cache/page_client-reference-manifest.js', 'force-cache/page_client-reference-manifest.js',
'hooks/use-search-params/with-suspense/page.js', 'hooks/use-search-params/with-suspense/page.js',
'variable-revalidate-edge/revalidate-3/page.js', 'variable-revalidate-edge/revalidate-3/page.js',
...@@ -640,10 +626,8 @@ createNextDescribe( ...@@ -640,10 +626,8 @@ createNextDescribe(
'stale-cache-serving-edge/route-handler/route.js', 'stale-cache-serving-edge/route-handler/route.js',
'blog/[author]/page_client-reference-manifest.js', 'blog/[author]/page_client-reference-manifest.js',
'default-cache/page_client-reference-manifest.js', 'default-cache/page_client-reference-manifest.js',
// 'force-dynamic-prerender/frameworks.prefetch.rsc',
'variable-config-revalidate/revalidate-3/page.js', 'variable-config-revalidate/revalidate-3/page.js',
'variable-revalidate/post-method-request/page.js', 'variable-revalidate/post-method-request/page.js',
// 'variable-revalidate/revalidate-360.prefetch.rsc',
'fetch-no-cache/page_client-reference-manifest.js', 'fetch-no-cache/page_client-reference-manifest.js',
'force-dynamic-catch-all/[slug]/[[...id]]/page.js', 'force-dynamic-catch-all/[slug]/[[...id]]/page.js',
'force-no-store/page_client-reference-manifest.js', 'force-no-store/page_client-reference-manifest.js',
...@@ -675,7 +659,6 @@ createNextDescribe( ...@@ -675,7 +659,6 @@ createNextDescribe(
'partial-gen-params-no-additional-lang/fr/second.html', 'partial-gen-params-no-additional-lang/fr/second.html',
'partial-gen-params-no-additional-slug/en/second.html', 'partial-gen-params-no-additional-slug/en/second.html',
'partial-gen-params-no-additional-slug/fr/second.html', 'partial-gen-params-no-additional-slug/fr/second.html',
// 'variable-revalidate/post-method-request.prefetch.rsc',
'variable-revalidate-edge/post-method-request/page.js', 'variable-revalidate-edge/post-method-request/page.js',
'force-static/[slug]/page_client-reference-manifest.js', 'force-static/[slug]/page_client-reference-manifest.js',
'blog/[author]/[slug]/page_client-reference-manifest.js', 'blog/[author]/[slug]/page_client-reference-manifest.js',
......
...@@ -2,8 +2,6 @@ import { createNextDescribe } from 'e2e-utils' ...@@ -2,8 +2,6 @@ import { createNextDescribe } from 'e2e-utils'
import { check, getRedboxHeader, hasRedbox, waitFor } from 'next-test-utils' import { check, getRedboxHeader, hasRedbox, waitFor } from 'next-test-utils'
import cheerio from 'cheerio' import cheerio from 'cheerio'
import stripAnsi from 'strip-ansi' import stripAnsi from 'strip-ansi'
import { BrowserInterface } from 'test/lib/browsers/base'
import { Request } from 'playwright-core'
createNextDescribe( createNextDescribe(
'app dir - basic', 'app dir - basic',
...@@ -37,60 +35,6 @@ createNextDescribe( ...@@ -37,60 +35,6 @@ createNextDescribe(
) )
}) })
// TODO: Re-enable once static prefetches re-land
it.skip('should use RSC prefetch data from build', async () => {
expect(
await next.readFile('.next/server/app/linking.prefetch.rsc')
).toBeTruthy()
expect(
await next.readFile('.next/server/app/linking/about.prefetch.rsc')
).toContain('About loading...')
expect(
await next.readFile(
'.next/server/app/dashboard/deployments/breakdown.prefetch.rsc'
)
).toBeTruthy()
expect(
await next
.readFile(
'.next/server/app/dashboard/deployments/[id].prefetch.rsc'
)
.catch(() => false)
).toBeFalsy()
const outputStart = next.cliOutput.length
const browser: BrowserInterface = await next.browser('/')
const rscReqs = []
browser.on('request', (req: Request) => {
if (req.headers()['rsc']) {
rscReqs.push(req.url())
}
})
await browser.eval('window.location.href = "/linking"')
await check(async () => {
return rscReqs.length > 3 ? 'success' : JSON.stringify(rscReqs)
}, 'success')
const trimmedOutput = next.cliOutput.substring(outputStart)
expect(trimmedOutput).not.toContain(
'rendering dashboard/(custom)/deployments/breakdown'
)
expect(trimmedOutput).not.toContain(
'rendering /dashboard/deployments/[id]'
)
expect(trimmedOutput).not.toContain('rendering linking about page')
await browser.elementByCss('#breakdown').click()
await check(
() => next.cliOutput.substring(outputStart),
/rendering .*breakdown/
)
})
if (!process.env.NEXT_EXPERIMENTAL_COMPILE) { if (!process.env.NEXT_EXPERIMENTAL_COMPILE) {
it('should have correct size in build output', async () => { it('should have correct size in build output', async () => {
expect(next.cliOutput).toMatch( expect(next.cliOutput).toMatch(
......
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