feat(nuxt): emit error in ssr-error event (#21547)

This commit is contained in:
Rodrigo Pimentel 2023-06-14 19:44:43 +01:00 committed by GitHub
parent 187230b0c5
commit b37ec72f8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -29,15 +29,19 @@ const NuxtClientFallbackServer = defineComponent({
default: () => false
}
},
emits: ['ssr-error'],
emits: {
'ssr-error' (_error: unknown) {
return true
}
},
setup (props, ctx) {
const vm = getCurrentInstance()
const ssrFailed = ref(false)
onErrorCaptured(() => {
onErrorCaptured((err) => {
useState(`${props.uid}`, () => true)
ssrFailed.value = true
ctx.emit('ssr-error')
ctx.emit('ssr-error', err)
return false
})
@ -50,10 +54,10 @@ const NuxtClientFallbackServer = defineComponent({
}
return { ssrFailed, ssrVNodes }
} catch {
} catch (ssrError) {
// catch in dev
useState(`${props.uid}`, () => true)
ctx.emit('ssr-error')
ctx.emit('ssr-error', ssrError)
return { ssrFailed: true, ssrVNodes: [] }
}
},