adding more robust handling for middleware headerSent

This commit is contained in:
Nick Galloway 2017-07-07 14:53:44 -05:00
parent 95c149f76b
commit 6a34d9a05a
2 changed files with 2 additions and 2 deletions

View File

@ -98,7 +98,7 @@ export default async (context) => {
if (!context.nuxt.error) { if (!context.nuxt.error) {
await middlewareSeries(midd, ctx) await middlewareSeries(midd, ctx)
} }
if (context.res.headersSent) return if (context.res && context.res.headersSent) return
if (context.redirected) return _noopApp if (context.redirected) return _noopApp
// Set layout // Set layout
let layout = Components.length ? Components[0].options.layout : NuxtError.layout let layout = Components.length ? Components[0].options.layout : NuxtError.layout

View File

@ -104,7 +104,7 @@ export function middlewareSeries (promises, context) {
} }
return promisify(promises[0], context) return promisify(promises[0], context)
.then(() => { .then(() => {
if (context.res.headersSent) return if (context.res && context.res.headersSent) return
return middlewareSeries(promises.slice(1), context) return middlewareSeries(promises.slice(1), context)
}) })
} }