Skip to content

Commit

Permalink
Refine logging message of experiments (#61337)
Browse files Browse the repository at this point in the history
Refining the message that uses "use with caution" instead of "use at
your own risk" as some experimental features was functionally stable but
we can't bring them as default for now and need to test as experiments

Closes NEXT-2286
  • Loading branch information
huozhi authored Jan 29, 2024
1 parent 1862b8a commit f0ea884
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion packages/next/src/cli/next-dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ const nextDev: CliCommand = async (args) => {
try {
if (!!args['--experimental-https']) {
Log.warn(
'Self-signed certificates are currently an experimental feature, use at your own risk.'
'Self-signed certificates are currently an experimental feature, use with caution.'
)

let certificate: SelfSignedCertificate | undefined
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/server/lib/app-info-log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function logStartInfo({
if (envInfo?.length) Log.bootstrap(` - Environments: ${envInfo.join(', ')}`)

if (expFeatureInfo?.length) {
Log.bootstrap(` - Experiments (use at your own risk):`)
Log.bootstrap(` - Experiments (use with caution):`)
// only show maximum 3 flags
for (const exp of expFeatureInfo.slice(0, maxExperimentalFeatures)) {
Log.bootstrap(` · ${exp}`)
Expand Down
5 changes: 2 additions & 3 deletions test/e2e/app-dir/app/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,8 @@ createNextDescribe(
it('should not have duplicate config warnings', async () => {
await next.fetch('/')
expect(
stripAnsi(next.cliOutput).match(
/Experiments \(use at your own risk\):/g
).length
stripAnsi(next.cliOutput).match(/Experiments \(use with caution\):/g)
.length
).toBe(1)
})
}
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/app-dir/ppr/ppr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ createNextDescribe(
({ next, isNextDev, isNextStart }) => {
it('should indicate the feature is experimental', async () => {
await check(() => {
return next.cliOutput.includes('Experiments (use at your own risk)') &&
return next.cliOutput.includes('Experiments (use with caution)') &&
next.cliOutput.includes('ppr')
? 'success'
: 'fail'
Expand Down
22 changes: 11 additions & 11 deletions test/integration/config-experimental-warning/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const appDir = join(__dirname, '..')
const configFile = new File(join(appDir, '/next.config.js'))
const configFileMjs = new File(join(appDir, '/next.config.mjs'))

const experimentalHeader = ' - Experiments (use with caution):'

let app
async function collectStdoutFromDev(appDir) {
let stdout = ''
Expand Down Expand Up @@ -57,7 +59,7 @@ describe('Config Experimental Warning', () => {
`)

const stdout = await collectStdoutFromDev(appDir)
expect(stdout).not.toMatch(' - Experiments (use at your own risk):')
expect(stdout).not.toMatch(experimentalHeader)
})

it('should not show warning with config from object', async () => {
Expand All @@ -68,7 +70,7 @@ describe('Config Experimental Warning', () => {
`)

const stdout = await collectStdoutFromDev(appDir)
expect(stdout).not.toMatch(' - Experiments (use at your own risk):')
expect(stdout).not.toMatch(experimentalHeader)
})

it('should show warning with config from object with experimental', async () => {
Expand All @@ -81,7 +83,7 @@ describe('Config Experimental Warning', () => {
`)

const stdout = await collectStdoutFromDev(appDir)
expect(stdout).toMatch(' - Experiments (use at your own risk):')
expect(stdout).toMatch(experimentalHeader)
expect(stdout).toMatch(' · workerThreads')
})

Expand All @@ -95,7 +97,7 @@ describe('Config Experimental Warning', () => {
`)

const stdout = await collectStdoutFromDev(appDir)
expect(stdout).toMatch(' - Experiments (use at your own risk):')
expect(stdout).toMatch(experimentalHeader)
expect(stdout).toMatch(' · workerThreads')
})

Expand All @@ -109,7 +111,7 @@ describe('Config Experimental Warning', () => {
`)

const stdout = await collectStdoutFromDev(appDir)
expect(stdout).not.toContain(' - Experiments (use at your own risk):')
expect(stdout).not.toContain(experimentalHeader)
expect(stdout).not.toContain(' · workerThreads')
})

Expand All @@ -124,7 +126,7 @@ describe('Config Experimental Warning', () => {
`)

const stdout = await collectStdoutFromDev(appDir)
expect(stdout).toContain(' - Experiments (use at your own risk):')
expect(stdout).toContain(experimentalHeader)
expect(stdout).toContain(' · workerThreads')
expect(stdout).toContain(' · scrollRestoration')
})
Expand All @@ -149,7 +151,7 @@ describe('Config Experimental Warning', () => {
stdout += msg
},
})
expect(stdout).not.toMatch(' - Experiments (use at your own risk):')
expect(stdout).not.toMatch(experimentalHeader)
})

it('should show next app info with all experimental features in next build', async () => {
Expand All @@ -164,7 +166,7 @@ describe('Config Experimental Warning', () => {
}
`)
const stdout = await collectStdoutFromBuild(appDir)
expect(stdout).toMatch(' - Experiments (use at your own risk):')
expect(stdout).toMatch(experimentalHeader)
expect(stdout).toMatch(' · cpus')
expect(stdout).toMatch(' · workerThreads')
expect(stdout).toMatch(' · scrollRestoration')
Expand Down Expand Up @@ -196,9 +198,7 @@ describe('Config Experimental Warning', () => {
await check(() => {
const cliOutput = stripAnsi(stdout)
const cliOutputErr = stripAnsi(stderr)
expect(cliOutput).not.toContain(
' - Experiments (use at your own risk):'
)
expect(cliOutput).not.toContain(experimentalHeader)
expect(cliOutputErr).toContain(
`Unrecognized key(s) in object: 'appDir' at "experimental"`
)
Expand Down

0 comments on commit f0ea884

Please sign in to comment.