Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused option and unified ready message into start server #55289

Merged
merged 6 commits into from Sep 12, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
99 changes: 61 additions & 38 deletions packages/next/src/server/lib/start-server.ts
Expand Up @@ -86,6 +86,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 Down Expand Up @@ -229,44 +277,8 @@ 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 + ''

// 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 +317,17 @@ export async function startServer({
process.exit(1)
}

if (logReady) {
logStartInfo({
port,
actualHostname,
appUrl,
hostname,
envInfo,
expFeatureInfo,
})
}

resolve()
})
server.listen(port, hostname)
Expand Down