From af10547dcaae12378a7ec57a7a69847df2192cbf Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 22 Mar 2022 15:40:43 +0530 Subject: [PATCH] warn if node is not launched with 'NODE_ENV=production' --- lib/env.js | 2 ++ server.js | 3 +++ 2 files changed, 5 insertions(+) diff --git a/lib/env.js b/lib/env.js index 1923dcc9e..516a9af7d 100644 --- a/lib/env.js +++ b/lib/env.js @@ -72,6 +72,8 @@ module.exports.create = function (config) { NO_SANDBOX: NO_SANDBOX, httpSafePort: httpSafePort, + NODE_ENV: process.env.NODE_ENV, + shouldUpdateNode: !isRecentVersion(), version: Package.version, diff --git a/server.js b/server.js index 80df1b526..30920abef 100644 --- a/server.js +++ b/server.js @@ -332,6 +332,9 @@ nThen(function (w) { currentVersion: process.version, }); } + if (Env.NODE_ENV !== 'production') { + Env.Log.warn("NODE_ENV", `If this server is running in a production context then it is recommended that you set NODE_ENV=production to prevent Expressjs from responding with stack traces when it catches an error.`); + } if (Env.OFFLINE_MODE) { return; } if (Env.websocketPath) { return; }