From a622c26d23694a99034f0c523de384e54510c763 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Mon, 11 Jul 2022 11:15:25 -0500 Subject: [PATCH 1/5] Add docs condition for all azure steps (#38519) --- azure-pipelines.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 8369ac1b8af3..5cd36b649e4c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -57,7 +57,10 @@ stages: condition: eq(variables['isDocsOnly'], 'No') - script: pnpm config set store-dir $(PNPM_CACHE_FOLDER) + condition: eq(variables['isDocsOnly'], 'No') + - script: pnpm store path + condition: eq(variables['isDocsOnly'], 'No') - script: pnpm install && pnpm run build condition: eq(variables['isDocsOnly'], 'No') @@ -92,7 +95,10 @@ stages: condition: eq(variables['isDocsOnly'], 'No') - script: pnpm config set store-dir $(PNPM_CACHE_FOLDER) + condition: eq(variables['isDocsOnly'], 'No') + - script: pnpm store path + condition: eq(variables['isDocsOnly'], 'No') - script: pnpm install && pnpm run build condition: eq(variables['isDocsOnly'], 'No') From 645f70128fb28abe1fc880bc8ab5cbb99a58c432 Mon Sep 17 00:00:00 2001 From: Thiago Morales Date: Mon, 11 Jul 2022 13:53:17 -0300 Subject: [PATCH 2/5] Pass missing incrementalCacheHandlerPath to IncrementalCache instance (#38433) # Description Hi guys! First all, thanks for provide a way to use some custom external cache resource for ISR feature. _(done here: https://github.com/vercel/next.js/pull/37258 and https://github.com/vercel/next.js/pull/37326)_ I managed to get it working by creating my custom external cache resource _(using redis)_ that implements the new `CacheHandler`. _(overriding my own `get` and `set` methods and using the FileSystemCache as fallback as well)_ I'm planning to release some kind of plugin to encapsulate and parse the client's `next.config.js` and bring an initial support for redis using this new Next.js feature. So, I really don't know if this was intentional, but I noticed that the new `incrementalCacheHandlerPath` prop wasn't passed to the `IncrementalCache` instance in `base-server`. This PR just connects the wires for this feature, and also provide the default value (`undefined`) to the relative experimental prop config. _(to avoid the warnings as shown below)_ Screen Shot 2022-07-07 at 19 37 46 --- packages/next/server/base-server.ts | 2 ++ packages/next/server/config-shared.ts | 1 + 2 files changed, 3 insertions(+) diff --git a/packages/next/server/base-server.ts b/packages/next/server/base-server.ts index e552fffdb60a..ccfa28e5dbfc 100644 --- a/packages/next/server/base-server.ts +++ b/packages/next/server/base-server.ts @@ -364,6 +364,8 @@ export default abstract class Server { serverDistDir: this.serverDistDir, maxMemoryCacheSize: this.nextConfig.experimental.isrMemoryCacheSize, flushToDisk: !minimalMode && this.nextConfig.experimental.isrFlushToDisk, + incrementalCacheHandlerPath: + this.nextConfig.experimental?.incrementalCacheHandlerPath, getPrerenderManifest: () => { if (dev) { return { diff --git a/packages/next/server/config-shared.ts b/packages/next/server/config-shared.ts index 3b55d24a08e2..3ca8aa5e75f4 100644 --- a/packages/next/server/config-shared.ts +++ b/packages/next/server/config-shared.ts @@ -534,6 +534,7 @@ export const defaultConfig: NextConfig = { appDir: false, // default to 50MB limit isrMemoryCacheSize: 50 * 1024 * 1024, + incrementalCacheHandlerPath: undefined, serverComponents: false, fullySpecified: false, outputFileTracingRoot: process.env.NEXT_PRIVATE_OUTPUT_TRACE_ROOT || '', From 0797b1a6c872781667595168c753efd119515564 Mon Sep 17 00:00:00 2001 From: Jiachi Liu Date: Mon, 11 Jul 2022 19:32:34 +0200 Subject: [PATCH 3/5] skip rsc tests for react 17 e2e (#38524) Fix flaky rsc test in react 17 e2e tests x-ref: https://github.com/vercel/next.js/runs/7285946966?check_suite_focus=true --- test/e2e/app-dir/rsc-basic.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/e2e/app-dir/rsc-basic.test.ts b/test/e2e/app-dir/rsc-basic.test.ts index 29c423445bbf..5b8fe2ab60d1 100644 --- a/test/e2e/app-dir/rsc-basic.test.ts +++ b/test/e2e/app-dir/rsc-basic.test.ts @@ -50,12 +50,12 @@ describe('app dir - react server components', () => { afterAll(() => next.destroy()) const { isNextDeploy, isNextDev } = global as any - if (isNextDeploy) { - it('should skip tests for next-deploy', () => {}) + const isReact17 = process.env.NEXT_TEST_REACT_VERSION === '^17' + if (isNextDeploy || isReact17) { + it('should skip tests for next-deploy and react 17', () => {}) return } - // TODO: support RSC index route it('should render server components correctly', async () => { const homeHTML = await renderViaHTTP(next.url, '/', null, { headers: { From 0036a3d1368b50b324f77f1743db7a3f7026894f Mon Sep 17 00:00:00 2001 From: OJ Kwon <1210596+kwonoj@users.noreply.github.com> Date: Mon, 11 Jul 2022 10:39:02 -0700 Subject: [PATCH 4/5] fix(next/build): correct payload for plugin telemetry (#38468) --- packages/next/telemetry/events/swc-plugins.ts | 8 ++++---- test/integration/telemetry/test/index.test.js | 14 ++++++-------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/packages/next/telemetry/events/swc-plugins.ts b/packages/next/telemetry/events/swc-plugins.ts index 329337d1af5b..7a0d9ee8473e 100644 --- a/packages/next/telemetry/events/swc-plugins.ts +++ b/packages/next/telemetry/events/swc-plugins.ts @@ -5,8 +5,8 @@ const EVENT_SWC_PLUGIN_PRESENT = 'NEXT_SWC_PLUGIN_DETECTED' type SwcPluginsEvent = { eventName: string payload: { - packageName: string - packageVersion?: string + pluginName: string + pluginVersion?: string } } @@ -34,8 +34,8 @@ export async function eventSwcPlugins( events.push({ eventName: EVENT_SWC_PLUGIN_PRESENT, payload: { - packageName: plugin, - packageVersion: version, + pluginName: plugin, + pluginVersion: version, }, }) diff --git a/test/integration/telemetry/test/index.test.js b/test/integration/telemetry/test/index.test.js index 7d65a87a069e..d4a810ed7015 100644 --- a/test/integration/telemetry/test/index.test.js +++ b/test/integration/telemetry/test/index.test.js @@ -843,19 +843,17 @@ describe('Telemetry CLI', () => { const regex = /NEXT_SWC_PLUGIN_DETECTED[\s\S]+?{([\s\S]+?)}/g const coverage = regex.exec(stderr).pop() - expect(coverage).toContain( - `"packageName": "swc-plugin-coverage-instrument"` - ) - expect(coverage).toContain(`"packageVersion": "0.0.6"`) + expect(coverage).toContain(`"pluginName": "swc-plugin-coverage-instrument"`) + expect(coverage).toContain(`"pluginVersion": "0.0.6"`) const relay = regex.exec(stderr).pop() - expect(relay).toContain(`"packageName": "@swc/plugin-relay"`) - expect(relay).toContain(`"packageVersion": "0.2.0"`) + expect(relay).toContain(`"pluginName": "@swc/plugin-relay"`) + expect(relay).toContain(`"pluginVersion": "0.2.0"`) const absolute = regex.exec(stderr).pop() expect(absolute).toContain( - `"packageName": "/test/absolute_path/plugin.wasm"` + `"pluginName": "/test/absolute_path/plugin.wasm"` ) - expect(absolute).not.toContain(`packageVersion`) + expect(absolute).not.toContain(`pluginVersion`) }) }) From 9222ca9f3f225469f9d1840cbfe7af365664b829 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Mon, 11 Jul 2022 14:54:57 -0500 Subject: [PATCH 5/5] Add dev/start timing to PR stats (#38525) * Add dev/start timing to PR stats * get port for dev * add dep * update field names --- .../src/run/collect-stats.js | 29 +++++++++- .../next-stats-action/src/run/index.js | 56 ++++++++++++++++++- test/.stats-app/stats-config.js | 1 + 3 files changed, 80 insertions(+), 6 deletions(-) diff --git a/.github/actions/next-stats-action/src/run/collect-stats.js b/.github/actions/next-stats-action/src/run/collect-stats.js index 0b585864d47b..de50a50f8842 100644 --- a/.github/actions/next-stats-action/src/run/collect-stats.js +++ b/.github/actions/next-stats-action/src/run/collect-stats.js @@ -35,6 +35,7 @@ module.exports = async function collectStats( (hasPagesToFetch || hasPagesToBench) ) { const port = await getPort() + const startTime = Date.now() const child = spawn(statsConfig.appStartCommand, { cwd: curDir, env: { @@ -44,14 +45,36 @@ module.exports = async function collectStats( }) let exitCode = null let logStderr = true - child.stdout.on('data', (data) => process.stdout.write(data)) + + let serverReadyResolve + let serverReadyResolved = false + const serverReadyPromise = new Promise((resolve) => { + serverReadyResolve = resolve + }) + + child.stdout.on('data', (data) => { + if (data.toString().includes('started server') && !serverReadyResolved) { + serverReadyResolved = true + serverReadyResolve() + } + process.stdout.write(data) + }) child.stderr.on('data', (data) => logStderr && process.stderr.write(data)) child.on('exit', (code) => { + if (!serverReadyResolved) { + serverReadyResolve() + serverReadyResolved = true + } exitCode = code }) - // give app a second to start up - await new Promise((resolve) => setTimeout(() => resolve(), 1500)) + + await serverReadyPromise + if (!orderedStats['General']) { + orderedStats['General'] = {} + } + orderedStats['General']['nextStartReadyDuration (ms)'] = + Date.now() - startTime if (exitCode !== null) { throw new Error( diff --git a/.github/actions/next-stats-action/src/run/index.js b/.github/actions/next-stats-action/src/run/index.js index 52d6a2f52499..0429da5ed9f4 100644 --- a/.github/actions/next-stats-action/src/run/index.js +++ b/.github/actions/next-stats-action/src/run/index.js @@ -1,5 +1,6 @@ const path = require('path') const fs = require('fs-extra') +const getPort = require('get-port') const glob = require('../util/glob') const exec = require('../util/exec') const logger = require('../util/logger') @@ -78,9 +79,9 @@ async function runConfigs( } const collectedStats = await collectStats(config, statsConfig) - curStats = { - ...curStats, - ...collectedStats, + + for (const key of Object.keys(collectedStats)) { + curStats[key] = Object.assign({}, curStats[key], collectedStats[key]) } const applyRenames = (renames, stats) => { @@ -156,6 +157,55 @@ async function runConfigs( env: yarnEnvValues, }) curStats.General.buildDurationCached = Date.now() - secondBuildStart + + if (statsConfig.appDevCommand) { + const port = await getPort() + const startTime = Date.now() + const child = exec.spawn(statsConfig.appDevCommand, { + cwd: statsAppDir, + env: { + PORT: port, + }, + stdio: 'pipe', + }) + + let serverReadyResolve + let serverReadyResolved = false + const serverReadyPromise = new Promise((resolve) => { + serverReadyResolve = resolve + }) + + child.stdout.on('data', (data) => { + if ( + data.toString().includes('started server') && + !serverReadyResolved + ) { + serverReadyResolved = true + serverReadyResolve() + } + process.stdout.write(data) + }) + child.stderr.on('data', (data) => process.stderr.write(data)) + + child.on('exit', (code) => { + if (!serverReadyResolved) { + serverReadyResolve() + serverReadyResolved = true + } + exitCode = code + }) + + setTimeout(() => { + if (!serverReadyResolved) { + child.kill() + } + }, 3 * 1000) + + await serverReadyPromise + child.kill() + + curStats['General']['nextDevReadyDuration'] = Date.now() - startTime + } } logger(`Finished running: ${config.title}`) diff --git a/test/.stats-app/stats-config.js b/test/.stats-app/stats-config.js index cac49071432e..6666afc0d9d0 100644 --- a/test/.stats-app/stats-config.js +++ b/test/.stats-app/stats-config.js @@ -68,6 +68,7 @@ module.exports = { commentReleaseHeading: 'Stats from current release', appBuildCommand: 'NEXT_TELEMETRY_DISABLED=1 yarn next build', appStartCommand: 'NEXT_TELEMETRY_DISABLED=1 yarn next start --port $PORT', + appDevCommand: 'NEXT_TELEMETRY_DISABLED=1 yarn next --port $PORT', mainRepo: 'vercel/next.js', mainBranch: 'canary', autoMergeMain: true,