Skip to content

Commit

Permalink
in development, block server start on warnServer (#22266)
Browse files Browse the repository at this point in the history
Part of #1029
  • Loading branch information
peterbe authored Oct 20, 2021
1 parent 884556e commit 0a32303
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ async function startServer() {
if (process.env.HEROKU_PRODUCTION_APP || process.env.GITHUB_ACTIONS) {
await warmServer()
}
} else {
// Warm up as soon as possible when in development.
// The `warmServer()` function is idempotent and it will soon be used
// by some middleware, but there's no point in having a started server
// without this warmed up. Besides, by starting this slow thing now,
// it can start immediately instead of waiting for the first request
// to trigger it to warm up. That way, when in development and triggering
// a `nodemon` restart, there's a good chance the warm up has come some
// way before you manage to reach for your browser to do a page refresh.
await warmServer()
}

// Workaround for https://github.com/expressjs/express/issues/1101
Expand Down

0 comments on commit 0a32303

Please sign in to comment.