Skip to content

Commit

Permalink
Merge branch 'canary' into fix/fetch-cache
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Nov 15, 2023
2 parents 9771083 + 375d85d commit 712a220
Show file tree
Hide file tree
Showing 27 changed files with 165 additions and 95 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
"registry": "https://registry.npmjs.org/"
}
},
"version": "14.0.3-canary.7"
"version": "14.0.3-canary.8"
}
2 changes: 1 addition & 1 deletion packages/create-next-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-next-app",
"version": "14.0.3-canary.7",
"version": "14.0.3-canary.8",
"keywords": [
"react",
"next",
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-config-next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-config-next",
"version": "14.0.3-canary.7",
"version": "14.0.3-canary.8",
"description": "ESLint configuration used by Next.js.",
"main": "index.js",
"license": "MIT",
Expand All @@ -10,7 +10,7 @@
},
"homepage": "https://nextjs.org/docs/app/building-your-application/configuring/eslint#eslint-config",
"dependencies": {
"@next/eslint-plugin-next": "14.0.3-canary.7",
"@next/eslint-plugin-next": "14.0.3-canary.8",
"@rushstack/eslint-patch": "^1.3.3",
"@typescript-eslint/parser": "^5.4.2 || ^6.0.0",
"eslint-import-resolver-node": "^0.3.6",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/eslint-plugin-next",
"version": "14.0.3-canary.7",
"version": "14.0.3-canary.8",
"description": "ESLint plugin for Next.js.",
"main": "dist/index.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/font/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/font",
"version": "14.0.3-canary.7",
"version": "14.0.3-canary.8",
"repository": {
"url": "vercel/next.js",
"directory": "packages/font"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-bundle-analyzer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/bundle-analyzer",
"version": "14.0.3-canary.7",
"version": "14.0.3-canary.8",
"main": "index.js",
"types": "index.d.ts",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-codemod/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/codemod",
"version": "14.0.3-canary.7",
"version": "14.0.3-canary.8",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-env/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/env",
"version": "14.0.3-canary.7",
"version": "14.0.3-canary.8",
"keywords": [
"react",
"next",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-mdx/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/mdx",
"version": "14.0.3-canary.7",
"version": "14.0.3-canary.8",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-storybook/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-storybook",
"version": "14.0.3-canary.7",
"version": "14.0.3-canary.8",
"repository": {
"url": "vercel/next.js",
"directory": "packages/next-plugin-storybook"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-polyfill-module/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-module",
"version": "14.0.3-canary.7",
"version": "14.0.3-canary.8",
"description": "A standard library polyfill for ES Modules supporting browsers (Edge 16+, Firefox 60+, Chrome 61+, Safari 10.1+)",
"main": "dist/polyfill-module.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-polyfill-nomodule/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-nomodule",
"version": "14.0.3-canary.7",
"version": "14.0.3-canary.8",
"description": "A polyfill for non-dead, nomodule browsers.",
"main": "dist/polyfill-nomodule.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-swc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/swc",
"version": "14.0.3-canary.7",
"version": "14.0.3-canary.8",
"private": true,
"scripts": {
"clean": "node ../../scripts/rm.mjs native",
Expand Down
14 changes: 7 additions & 7 deletions packages/next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next",
"version": "14.0.3-canary.7",
"version": "14.0.3-canary.8",
"description": "The React Framework",
"main": "./dist/server/next.js",
"license": "MIT",
Expand Down Expand Up @@ -92,7 +92,7 @@
]
},
"dependencies": {
"@next/env": "14.0.3-canary.7",
"@next/env": "14.0.3-canary.8",
"@swc/helpers": "0.5.2",
"busboy": "1.6.0",
"caniuse-lite": "^1.0.30001406",
Expand Down Expand Up @@ -146,11 +146,11 @@
"@mswjs/interceptors": "0.23.0",
"@napi-rs/cli": "2.16.2",
"@napi-rs/triples": "1.1.0",
"@next/polyfill-module": "14.0.3-canary.7",
"@next/polyfill-nomodule": "14.0.3-canary.7",
"@next/react-dev-overlay": "14.0.3-canary.7",
"@next/react-refresh-utils": "14.0.3-canary.7",
"@next/swc": "14.0.3-canary.7",
"@next/polyfill-module": "14.0.3-canary.8",
"@next/polyfill-nomodule": "14.0.3-canary.8",
"@next/react-dev-overlay": "14.0.3-canary.8",
"@next/react-refresh-utils": "14.0.3-canary.8",
"@next/swc": "14.0.3-canary.8",
"@opentelemetry/api": "1.6.0",
"@playwright/test": "^1.35.1",
"@taskr/clear": "1.1.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/next/src/export/routes/app-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import { isDynamicUsageError } from '../helpers/is-dynamic-usage-error'
import {
NEXT_CACHE_TAGS_HEADER,
NEXT_META_SUFFIX,
RSC_PREFETCH_SUFFIX,
RSC_SUFFIX,
} from '../../lib/constants'
Expand Down Expand Up @@ -206,7 +207,7 @@ export async function exportAppPage(

await fileWriter(
ExportedAppPageFiles.META,
htmlFilepath.replace(/\.html$/, '.meta'),
htmlFilepath.replace(/\.html$/, NEXT_META_SUFFIX),
JSON.stringify(meta, null, 2)
)

Expand Down
10 changes: 7 additions & 3 deletions packages/next/src/export/routes/app-route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import type { AppRouteRouteHandlerContext } from '../../server/future/route-modu
import type { IncrementalCache } from '../../server/lib/incremental-cache'

import { join } from 'path'
import { NEXT_CACHE_TAGS_HEADER } from '../../lib/constants'
import {
NEXT_BODY_SUFFIX,
NEXT_CACHE_TAGS_HEADER,
NEXT_META_SUFFIX,
} from '../../lib/constants'
import { NodeNextRequest } from '../../server/base-http/node'
import { RouteModuleLoader } from '../../server/future/helpers/module-loader/route-module-loader'
import {
Expand Down Expand Up @@ -104,7 +108,7 @@ export async function exportAppRoute(
const body = Buffer.from(await blob.arrayBuffer())
await fileWriter(
ExportedAppRouteFiles.BODY,
htmlFilepath.replace(/\.html$/, '.body'),
htmlFilepath.replace(/\.html$/, NEXT_BODY_SUFFIX),
body,
'utf8'
)
Expand All @@ -113,7 +117,7 @@ export async function exportAppRoute(
const meta = { status: response.status, headers }
await fileWriter(
ExportedAppRouteFiles.META,
htmlFilepath.replace(/\.html$/, '.meta'),
htmlFilepath.replace(/\.html$/, NEXT_META_SUFFIX),
JSON.stringify(meta)
)

Expand Down
7 changes: 5 additions & 2 deletions packages/next/src/export/routes/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import type {
MockedResponse,
} from '../../server/lib/mock-request'
import { isInAmpMode } from '../../shared/lib/amp-mode'
import { SERVER_PROPS_EXPORT_ERROR } from '../../lib/constants'
import {
NEXT_DATA_SUFFIX,
SERVER_PROPS_EXPORT_ERROR,
} from '../../lib/constants'
import { NEXT_DYNAMIC_NO_SSR_CODE } from '../../shared/lib/lazy-dynamic/no-ssr-error'
import AmpHtmlValidator from 'next/dist/compiled/amphtml-validator'
import { FileType, fileExists } from '../../lib/file-exists'
Expand Down Expand Up @@ -187,7 +190,7 @@ export async function exportPages(
if (metadata.pageData) {
const dataFile = join(
pagesDataDir,
htmlFilename.replace(/\.html$/, '.json')
htmlFilename.replace(/\.html$/, NEXT_DATA_SUFFIX)
)

await fileWriter(
Expand Down
3 changes: 3 additions & 0 deletions packages/next/src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ export const NEXT_DID_POSTPONE_HEADER = 'x-nextjs-postponed'

export const RSC_PREFETCH_SUFFIX = '.prefetch.rsc'
export const RSC_SUFFIX = '.rsc'
export const NEXT_DATA_SUFFIX = '.json'
export const NEXT_META_SUFFIX = '.meta'
export const NEXT_BODY_SUFFIX = '.body'

export const NEXT_CACHE_TAGS_HEADER = 'x-next-cache-tags'
export const NEXT_CACHE_SOFT_TAGS_HEADER = 'x-next-cache-soft-tags'
Expand Down
13 changes: 9 additions & 4 deletions packages/next/src/server/base-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2453,10 +2453,9 @@ export default abstract class Server<ServerOptions extends Options = Options> {
ssgCacheKey,
async (
hasResolved,
previousCacheEntry
previousCacheEntry,
isRevalidating
): Promise<ResponseCacheEntry | null> => {
// If this is a resume request, get the postponed.
const postponed = resumed ? resumed.postponed : undefined
const isProduction = !this.renderOpts.dev
const didRespond = hasResolved || res.sent

Expand Down Expand Up @@ -2494,6 +2493,12 @@ export default abstract class Server<ServerOptions extends Options = Options> {
isOnDemandRevalidate = true
}

// Only requests that aren't revalidating can be resumed.
const postponed =
!isOnDemandRevalidate && !isRevalidating && resumed
? resumed.postponed
: undefined

// only allow on-demand revalidate for fallback: true/blocking
// or for prerendered fallback: false paths
if (
Expand Down Expand Up @@ -2603,7 +2608,7 @@ export default abstract class Server<ServerOptions extends Options = Options> {
{
routeKind: routeModule?.definition.kind,
incrementalCache,
isOnDemandRevalidate: isOnDemandRevalidate,
isOnDemandRevalidate,
isPrefetch: req.headers.purpose === 'prefetch',
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import LRUCache from 'next/dist/compiled/lru-cache'
import path from '../../../shared/lib/isomorphic/path'
import {
NEXT_CACHE_TAGS_HEADER,
NEXT_DATA_SUFFIX,
NEXT_META_SUFFIX,
RSC_PREFETCH_SUFFIX,
RSC_SUFFIX,
} from '../../../lib/constants'
Expand Down Expand Up @@ -128,7 +130,10 @@ export default class FileSystemCache implements CacheHandler {
const { mtime } = await this.fs.stat(filePath)

const meta = JSON.parse(
await this.fs.readFile(filePath.replace(/\.body$/, '.meta'), 'utf8')
await this.fs.readFile(
filePath.replace(/\.body$/, NEXT_META_SUFFIX),
'utf8'
)
)

const cacheEntry: CacheHandlerValue = {
Expand Down Expand Up @@ -192,7 +197,7 @@ export default class FileSystemCache implements CacheHandler {
)
: JSON.parse(
await this.fs.readFile(
this.getFilePath(`${key}.json`, 'pages'),
this.getFilePath(`${key}${NEXT_DATA_SUFFIX}`, 'pages'),
'utf8'
)
)
Expand All @@ -203,7 +208,7 @@ export default class FileSystemCache implements CacheHandler {
try {
meta = JSON.parse(
await this.fs.readFile(
filePath.replace(/\.html$/, '.meta'),
filePath.replace(/\.html$/, NEXT_META_SUFFIX),
'utf8'
)
)
Expand Down Expand Up @@ -305,7 +310,7 @@ export default class FileSystemCache implements CacheHandler {
}

await this.fs.writeFile(
filePath.replace(/\.body$/, '.meta'),
filePath.replace(/\.body$/, NEXT_META_SUFFIX),
JSON.stringify(meta, null, 2)
)
return
Expand All @@ -322,7 +327,13 @@ export default class FileSystemCache implements CacheHandler {

await this.fs.writeFile(
this.getFilePath(
`${key}.${isAppPath ? 'rsc' : 'json'}`,
`${key}${
isAppPath
? this.experimental.ppr
? RSC_PREFETCH_SUFFIX
: RSC_SUFFIX
: NEXT_DATA_SUFFIX
}`,
isAppPath ? 'app' : 'pages'
),
isAppPath ? data.pageData : JSON.stringify(data.pageData)
Expand All @@ -336,7 +347,7 @@ export default class FileSystemCache implements CacheHandler {
}

await this.fs.writeFile(
htmlPath.replace(/\.html$/, '.meta'),
htmlPath.replace(/\.html$/, NEXT_META_SUFFIX),
JSON.stringify(meta)
)
}
Expand Down
Loading

0 comments on commit 712a220

Please sign in to comment.