From b9eaf27e563bb83258b09c09df5eaf5ff250d4b2 Mon Sep 17 00:00:00 2001 From: Nazar Gargol Date: Mon, 1 Apr 2019 15:02:21 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fixed=20admin=20error=20page=20o?= =?UTF-8?q?n=20startup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes #10616 - The check should be on empty object because that's the default state of expresses 'engines' property - https://github.com/expressjs/express/blob/3ed5090ca91f6a387e66370d57ead94d886275e1/lib/application.js#L59 - The bug was introduced with https://github.com/TryGhost/Ghost/commit/5e963935f932cf1c6dfaf44574d69bd3980939b2#diff-04cc23b216e11161ab7267d69f13d004R142 --- core/server/web/shared/middlewares/error-handler.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/server/web/shared/middlewares/error-handler.js b/core/server/web/shared/middlewares/error-handler.js index 928e9eb8bb..ba0f814a3b 100644 --- a/core/server/web/shared/middlewares/error-handler.js +++ b/core/server/web/shared/middlewares/error-handler.js @@ -168,7 +168,7 @@ _private.ThemeErrorRenderer = (err, req, res, next) => { // It can be that something went wrong with the theme or otherwise loading handlebars // This ensures that no matter what res.render will work here // @TODO: split the error handler for assets, admin & theme to refactor this away - if (!req.app.engines || Object.keys(req.app.engines).length === 0) { + if (_.isEmpty(req.app.engines)) { res._template = 'error'; req.app.engine('hbs', _private.createHbsEngine()); req.app.set('view engine', 'hbs'); @@ -201,7 +201,7 @@ _private.HTMLErrorRenderer = (err, req, res, next) => { // eslint-disable-line n // e.g. if you serve the admin /ghost and Ghost returns a 503 because it generates the urls at the moment. // This ensures that no matter what res.render will work here // @TODO: put to prepare error function? - if (!req.app.engines || req.app.engines.length === 0) { + if (_.isEmpty(req.app.engines)) { res._template = 'error'; req.app.engine('hbs', _private.createHbsEngine()); req.app.set('view engine', 'hbs');