Skip to content

Commit

Permalink
fix: call server.listen() before accessing server.address() to get th…
Browse files Browse the repository at this point in the history
…e actual address; restore original for startup duration
  • Loading branch information
dominikg committed Sep 26, 2021
1 parent 6b54ce7 commit 29dd8d1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
13 changes: 5 additions & 8 deletions packages/vite/src/node/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,16 @@ cli
throw new Error('HTTP server not available')
}

await server.listen()

printHttpServerUrls(server.httpServer, server.config, options)

// @ts-ignore
if (global.__vite_start_time) {
info(
chalk.cyan(
// @ts-ignore
performance.now() - global.__vite_start_time
)
)
// @ts-ignore
const startupDuration = performance.now() - global.__vite_start_time
info(`\n ${chalk.cyan(`ready in ${Math.ceil(startupDuration)}ms.`)}\n`)
}

await server.listen()
} catch (e) {
createLogger(options.logLevel).error(
chalk.red(`error when starting dev server:\n${e.stack}`),
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export function printHttpServerUrls(
}
}

export function printServerUrls(
function printServerUrls(
hostname: Hostname,
protocol: string,
port: number,
Expand Down

0 comments on commit 29dd8d1

Please sign in to comment.