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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading