From 6a34d9a05ad417579cc06dbb85eec34f140d62c3 Mon Sep 17 00:00:00 2001 From: Nick Galloway Date: Fri, 7 Jul 2017 14:53:44 -0500 Subject: [PATCH] adding more robust handling for middleware headerSent --- lib/app/server.js | 2 +- lib/app/utils.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/app/server.js b/lib/app/server.js index 0c0b2a5c9d..53f2922461 100644 --- a/lib/app/server.js +++ b/lib/app/server.js @@ -98,7 +98,7 @@ export default async (context) => { if (!context.nuxt.error) { await middlewareSeries(midd, ctx) } - if (context.res.headersSent) return + if (context.res && context.res.headersSent) return if (context.redirected) return _noopApp // Set layout let layout = Components.length ? Components[0].options.layout : NuxtError.layout diff --git a/lib/app/utils.js b/lib/app/utils.js index fa1c3664fa..99e45afc8f 100644 --- a/lib/app/utils.js +++ b/lib/app/utils.js @@ -104,7 +104,7 @@ export function middlewareSeries (promises, context) { } return promisify(promises[0], context) .then(() => { - if (context.res.headersSent) return + if (context.res && context.res.headersSent) return return middlewareSeries(promises.slice(1), context) }) }