Skip to content

Commit 602fd9a

Browse files
authored
always warm the sever before listening (#23750)
1 parent 44df555 commit 602fd9a

1 file changed

Lines changed: 9 additions & 17 deletions

File tree

server.mjs

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,15 @@ async function checkPortAvailability() {
5252
async function startServer() {
5353
const app = createApp()
5454

55-
// If in a deployed environment...
56-
if (NODE_ENV === 'production') {
57-
// If in a true production environment, wait for the cache to be fully warmed.
58-
if (process.env.HEROKU_PRODUCTION_APP || process.env.GITHUB_ACTIONS) {
59-
await warmServer()
60-
}
61-
} else {
62-
// Warm up as soon as possible when in development.
63-
// The `warmServer()` function is idempotent and it will soon be used
64-
// by some middleware, but there's no point in having a started server
65-
// without this warmed up. Besides, by starting this slow thing now,
66-
// it can start immediately instead of waiting for the first request
67-
// to trigger it to warm up. That way, when in development and triggering
68-
// a `nodemon` restart, there's a good chance the warm up has come some
69-
// way before you manage to reach for your browser to do a page refresh.
70-
await warmServer()
71-
}
55+
// Warm up as soon as possible.
56+
// The `warmServer()` function is idempotent and it will soon be used
57+
// by some middleware, but there's no point in having a started server
58+
// without this warmed up. Besides, by starting this slow thing now,
59+
// it can start immediately instead of waiting for the first request
60+
// to trigger it to warm up. That way, when in development and triggering
61+
// a `nodemon` restart, there's a good chance the warm up has come some
62+
// way before you manage to reach for your browser to do a page refresh.
63+
await warmServer()
7264

7365
// Workaround for https://github.com/expressjs/express/issues/1101
7466
const server = http.createServer(app)

0 commit comments

Comments
 (0)