Unverified Commit 440560fb authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Ensure config warnings only show once (#45142)

Since we now call `loadConfig()` in various processes our `execOnce`
handling isn't tracking when we have already shown warnings/logs in
another process so this adds a `silent` flag that we can leverage when
calling `loadConfig()`.

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

Fixes: [slack
thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1674351677627259)
parent 70282b72
...@@ -35,7 +35,13 @@ const handleSessionStop = async () => { ...@@ -35,7 +35,13 @@ const handleSessionStop = async () => {
const { eventCliSession } = const { eventCliSession } =
require('../telemetry/events/session-stopped') as typeof import('../telemetry/events/session-stopped') require('../telemetry/events/session-stopped') as typeof import('../telemetry/events/session-stopped')
const config = await loadConfig(PHASE_DEVELOPMENT_SERVER, dir) const config = await loadConfig(
PHASE_DEVELOPMENT_SERVER,
dir,
undefined,
undefined,
true
)
let telemetry = let telemetry =
(traceGlobals.get('telemetry') as InstanceType< (traceGlobals.get('telemetry') as InstanceType<
...@@ -493,7 +499,13 @@ If you cannot make the changes above, but still want to try out\nNext.js v13 wit ...@@ -493,7 +499,13 @@ If you cannot make the changes above, but still want to try out\nNext.js v13 wit
cluster.settings.stdio = ['ipc', 'pipe', 'pipe'] cluster.settings.stdio = ['ipc', 'pipe', 'pipe']
setupFork() setupFork()
config = await loadConfig(PHASE_DEVELOPMENT_SERVER, dir) config = await loadConfig(
PHASE_DEVELOPMENT_SERVER,
dir,
undefined,
undefined,
true
)
const handleProjectDirRename = (newDir: string) => { const handleProjectDirRename = (newDir: string) => {
clusterExitUnsub() clusterExitUnsub()
......
This diff is collapsed.
...@@ -20,7 +20,13 @@ import { PHASE_DEVELOPMENT_SERVER } from '../shared/lib/constants' ...@@ -20,7 +20,13 @@ import { PHASE_DEVELOPMENT_SERVER } from '../shared/lib/constants'
} }
dir = getProjectDir(dir) dir = getProjectDir(dir)
const config = await loadConfig(PHASE_DEVELOPMENT_SERVER, dir) const config = await loadConfig(
PHASE_DEVELOPMENT_SERVER,
dir,
undefined,
undefined,
true
)
const distDir = path.join(dir, config.distDir || '.next') const distDir = path.join(dir, config.distDir || '.next')
const eventsPath = path.join(distDir, '_events.json') const eventsPath = path.join(distDir, '_events.json')
......
...@@ -247,7 +247,7 @@ export class Telemetry { ...@@ -247,7 +247,7 @@ export class Telemetry {
JSON.stringify(allEvents) JSON.stringify(allEvents)
) )
spawn(process.execPath, [require.resolve('./deteched-flush'), mode, dir], { spawn(process.execPath, [require.resolve('./detached-flush'), mode, dir], {
detached: !this.NEXT_TELEMETRY_DEBUG, detached: !this.NEXT_TELEMETRY_DEBUG,
windowsHide: true, windowsHide: true,
shell: false, shell: false,
......
...@@ -2,6 +2,7 @@ import { createNextDescribe } from 'e2e-utils' ...@@ -2,6 +2,7 @@ import { createNextDescribe } from 'e2e-utils'
import crypto from 'crypto' import crypto from 'crypto'
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'
createNextDescribe( createNextDescribe(
'app dir', 'app dir',
...@@ -15,6 +16,22 @@ createNextDescribe( ...@@ -15,6 +16,22 @@ createNextDescribe(
}, },
}, },
({ next, isNextDev: isDev, isNextStart, isNextDeploy }) => { ({ next, isNextDev: isDev, isNextStart, isNextDeploy }) => {
if (isDev) {
it('should not have duplicate config warnings', async () => {
await next.fetch('/')
expect(
stripAnsi(next.cliOutput).match(
/You have enabled experimental feature/g
).length
).toBe(1)
expect(
stripAnsi(next.cliOutput).match(
/Experimental features are not covered by semver/g
).length
).toBe(1)
})
}
if (!isNextDeploy) { if (!isNextDeploy) {
it('should not share edge workers', async () => { it('should not share edge workers', async () => {
const controller1 = new AbortController() const controller1 = new AbortController()
......
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