Skip to content

Commit f312814

Browse files
authored
Put the 'await' back with 'warmServer' for true production startup (#16765)
1 parent 7a52639 commit f312814

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

server.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,17 @@ if (!module.parent) {
1616
// check that the development server is not already running
1717
portUsed.check(port).then(async status => {
1818
if (status === false) {
19-
// If in production, warm the server at the start
20-
if (process.env.NODE_ENV === 'production') warmServer()
19+
// If in a deployed environment, warm the server at the start
20+
if (process.env.NODE_ENV === 'production') {
21+
// If in a true production environment, wait for the cache to be fully warmed.
22+
if (process.env.HEROKU_PRODUCTION_APP) {
23+
await warmServer()
24+
} else {
25+
// If not in a true production environment, don't wait for the cache to be fully warmed.
26+
// This avoids deployment timeouts in environments with slower servers.
27+
warmServer()
28+
}
29+
}
2130

2231
// workaround for https://github.com/expressjs/express/issues/1101
2332
const server = require('http').createServer(app)

0 commit comments

Comments
 (0)