`errorCaptured` not triggered by error in `async setup` during SSR
Version
3.0.4
Reproduction link
https://codesandbox.io/s/ssr-async-setup-error-4tfiq?file=/src/index.js:0-1145
Steps to reproduce
const { createSSRApp, defineComponent } = require('vue')
const { renderToString } = require('@vue/server-renderer')
const children = defineComponent({
name: 'child1',
setup() {
// some error...
throw new Error('child1 error!')
},
template: `<div class="children">{{ test }}</div>`
})
const asyncChildren = defineComponent({
name: 'asyncChildren',
async setup() {
// some async error...
// e.g. axios.fetch...
// throw new Error('async child error!')
return Promise.reject('async child error!')
},
template: `<div class="async-children">{{ test.abc }}</div>`
})
const app = createSSRApp({
name: 'App',
components: {
children,
asyncChildren
},
template:
`
<div class="app">
<suspense>
<children />
<async-children />
</suspense>
</div>
`,
errorCaptured(error) {
console.log('-----errorCaptured', error)
}
})
app.config.errorHandler = (error) => {
console.log('-----errorHandler', error)
}
renderToString(app).then(res => {
console.log('----renderToString', res)
}).catch(error => {
console.log('----renderToString error', error)
})
What is expected?
async setup function can throw async error to parent.
What is actually happening?
no handle async error.
onErrorCaptured
hook and errorHandler
can capture the async error, but not capture the async setup function async error.
In the package server-renderer
, there is also no error handling for serverPrefetch
and async setup