From f3128142190719cdac785ba2c348302e048f8f79 Mon Sep 17 00:00:00 2001 From: "James M. Greene" Date: Mon, 7 Dec 2020 15:16:08 -0600 Subject: [PATCH] Put the 'await' back with 'warmServer' for true production startup (#16765) --- server.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/server.js b/server.js index 1af6650790b9..ce00b05169f1 100644 --- a/server.js +++ b/server.js @@ -16,8 +16,17 @@ if (!module.parent) { // check that the development server is not already running portUsed.check(port).then(async status => { if (status === false) { - // If in production, warm the server at the start - if (process.env.NODE_ENV === 'production') warmServer() + // If in a deployed environment, warm the server at the start + if (process.env.NODE_ENV === 'production') { + // If in a true production environment, wait for the cache to be fully warmed. + if (process.env.HEROKU_PRODUCTION_APP) { + await warmServer() + } else { + // If not in a true production environment, don't wait for the cache to be fully warmed. + // This avoids deployment timeouts in environments with slower servers. + warmServer() + } + } // workaround for https://github.com/expressjs/express/issues/1101 const server = require('http').createServer(app)