perf(nuxt): abort vue render when plugins throw error (#27304)

This commit is contained in:
Daniel Roe 2024-05-22 15:40:19 +01:00 committed by GitHub
parent 8a759bc6fe
commit eb0bebc46d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,7 +1,8 @@
<template>
<Suspense @resolve="onResolve">
<div v-if="abortRender" />
<ErrorComponent
v-if="error"
v-else-if="error"
:error="error"
/>
<IslandRenderer
@ -53,6 +54,8 @@ if (import.meta.dev && results && results.some(i => i && 'then' in i)) {
// error handling
const error = useError()
// render an empty <div> when plugins have thrown an error but we're not yet rendering the error page
const abortRender = import.meta.server && error.value && !nuxtApp.ssrContext.error
onErrorCaptured((err, target, info) => {
nuxtApp.hooks.callHook('vue:error', err, target, info).catch(hookError => console.error('[nuxt] Error in `vue:error` hook', hookError))
if (import.meta.server || (isNuxtError(err) && (err.fatal || err.unhandled))) {