Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
fix(nuxt): preserve render errors (#8884)
Browse files Browse the repository at this point in the history
* fix(nuxt): preserve render errors

* simplify logic
  • Loading branch information
pi0 authored Nov 10, 2022
1 parent 0ff4ebe commit 83b5c09
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions packages/nuxt/src/core/runtime/nitro/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,18 +172,13 @@ export default defineRenderHandler(async (event) => {
writeEarlyHints(event, link)
}

const _rendered = await renderer.renderToString(ssrContext).catch((err) => {
if (!ssrError) {
// Use explicitly thrown error in preference to subsequent rendering errors
throw ssrContext.payload?.error || err
}
const _rendered = await renderer.renderToString(ssrContext).catch((error) => {
// Use explicitly thrown error in preference to subsequent rendering errors
throw (!ssrError && ssrContext.payload?.error) || error
})
await ssrContext.nuxt?.hooks.callHook('app:rendered', { ssrContext })

// Handle errors
if (!_rendered) {
return undefined!
}
if (ssrContext.payload?.error && !ssrError) {
throw ssrContext.payload.error
}
Expand Down

0 comments on commit 83b5c09

Please sign in to comment.