From c01e1420313770d0f493f67819debf27ee8ececa Mon Sep 17 00:00:00 2001 From: Dorian Niemiec Date: Tue, 23 Jul 2024 21:21:53 +0200 Subject: [PATCH] Errors with Next.js itself now cause 500 errors instead of 503 errors. --- index.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index bd093d0..05cbd9a 100644 --- a/index.js +++ b/index.js @@ -6,7 +6,6 @@ var dev = process.env.NODE_ENV == "development"; var handle = function () { throw nextError; } -var appPreparationError = null; var isPrepared = false; var configJSON = {}; @@ -49,7 +48,7 @@ try { handle = initResponse[0]; isPrepared = true; } catch (err) { - appPreparationError = err; + nextError = err; } } init(); @@ -77,7 +76,7 @@ try { app.prepare().then(function () { isPrepared = true; }).catch(function (err) { - appPreparationError = err; + nextError = err; }); } catch (err) { nextError = err; @@ -89,7 +88,7 @@ function Mod() {} Mod.prototype.callback = function callback(req, res, serverconsole, responseEnd, href, ext, uobject, search, defaultpage, users, page404, head, foot, fd, elseCallback, configJSON, callServerError, getCustomHeaders, origHref, redirect, parsePostData) { return async function () { try { - if (appPreparationError) throw appPreparationError; + if (nextError) throw nextError; if (!isPrepared) { callServerError(503, "nextjs-integration/1.0.0"); serverconsole.errmessage("Next.js application not yet fully loaded.");