Skip to content

Commit

Permalink
Remove unused option and unified ready message into start server (ver…
Browse files Browse the repository at this point in the history
…cel#55289)

Remove the `logReady` optional option introduced in vercel#52492, never being passdown but alwasy `true` by default.
  • Loading branch information
huozhi authored Sep 12, 2023
1 parent 6e3c4e2 commit 85d30b6
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 44 deletions.
1 change: 0 additions & 1 deletion packages/next/src/build/output/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ store.subscribe((state) => {
}

if (trigger === 'initial') {
Log.event('ready')
trigger = ''
} else if (trigger) {
if (loadingLogTimer) {
Expand Down
2 changes: 0 additions & 2 deletions packages/next/src/server/lib/router-utils/setup-dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -953,8 +953,6 @@ async function startWatcher(opts: SetupOpts) {
// Not implemented yet.
},
async start() {
// Align with nextjs logging for ready start event
Log.event('ready')
// Not implemented yet.
},
async stop() {
Expand Down
99 changes: 60 additions & 39 deletions packages/next/src/server/lib/start-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ if (process.env.NEXT_CPU_PROF) {
export interface StartServerOptions {
dir: string
port: number
logReady?: boolean
isDev: boolean
hostname: string
allowRetry?: boolean
Expand Down Expand Up @@ -86,6 +85,54 @@ export async function getRequestHandlers({
})
}

function logStartInfo({
port,
actualHostname,
appUrl,
hostname,
envInfo,
expFeatureInfo,
}: {
port: number
actualHostname: string
appUrl: string
hostname: string
envInfo: string[] | undefined
expFeatureInfo: string[] | undefined
}) {
Log.bootstrap(
chalk.bold(
chalk.hex('#ad7fa8')(
` ${`${Log.prefixes.ready} Next.js`} ${process.env.__NEXT_VERSION}`
)
)
)
Log.bootstrap(` - Local: ${appUrl}`)
if (hostname) {
Log.bootstrap(
` - Network: ${actualHostname}${
(port + '').startsWith(':') ? '' : ':'
}${port}`
)
}
if (envInfo?.length) Log.bootstrap(` - Environments: ${envInfo.join(', ')}`)

if (expFeatureInfo?.length) {
Log.bootstrap(` - Experiments (use at your own risk):`)
// only show maximum 3 flags
for (const exp of expFeatureInfo.slice(0, 3)) {
Log.bootstrap(` · ${exp}`)
}
/* ${expFeatureInfo.length - 3} more */
if (expFeatureInfo.length > 3) {
Log.bootstrap(` · ...`)
}
}

// New line after the bootstrap info
Log.info('')
}

export async function startServer({
dir,
port,
Expand All @@ -95,7 +142,6 @@ export async function startServer({
allowRetry,
keepAliveTimeout,
isExperimentalTestProxy,
logReady = true,
selfSignedCertificate,
envInfo,
expFeatureInfo,
Expand Down Expand Up @@ -229,44 +275,17 @@ export async function startServer({
)
}

if (logReady) {
Log.bootstrap(
chalk.bold(
chalk.hex('#ad7fa8')(
` ${`${Log.prefixes.ready} Next.js`} ${
process.env.__NEXT_VERSION
}`
)
)
)
Log.bootstrap(` - Local: ${appUrl}`)
if (hostname) {
Log.bootstrap(
` - Network: ${actualHostname}${
(port + '').startsWith(':') ? '' : ':'
}${port}`
)
}
if (envInfo?.length)
Log.bootstrap(` - Environments: ${envInfo.join(', ')}`)

if (expFeatureInfo?.length) {
Log.bootstrap(` - Experiments (use at your own risk):`)
// only show maximum 3 flags
for (const exp of expFeatureInfo.slice(0, 3)) {
Log.bootstrap(` · ${exp}`)
}
/* ${expFeatureInfo.length - 3} more */
if (expFeatureInfo.length > 3) {
Log.bootstrap(` · ...`)
}
}
// expose the main port to render workers
process.env.PORT = port + ''
logStartInfo({
port,
actualHostname,
appUrl,
hostname,
envInfo,
expFeatureInfo,
})

// New line after the bootstrap info
Log.info('')
}
// expose the main port to render workers
process.env.PORT = port + ''

try {
const cleanup = (code: number | null) => {
Expand Down Expand Up @@ -305,6 +324,8 @@ export async function startServer({
process.exit(1)
}

Log.event('ready')

resolve()
})
server.listen(port, hostname)
Expand Down
4 changes: 2 additions & 2 deletions test/integration/nullish-config/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const runTests = (type) => {
const stdout = await getStdout()

if (type === 'dev') {
expect(stdout).toMatch(/- Local:/i)
expect(stdout).toMatch(/ready/i)
} else {
expect(stdout).toMatch(/Compiled successfully/i)
}
Expand All @@ -53,7 +53,7 @@ const runTests = (type) => {
const stdout = await getStdout()

if (type === 'dev') {
expect(stdout).toMatch(/- Local:/i)
expect(stdout).toMatch(/ready/i)
} else {
expect(stdout).toMatch(/Compiled successfully/i)
}
Expand Down

0 comments on commit 85d30b6

Please sign in to comment.