fix(ssr): ensure async setup error handling work with suspense during ssr
This commit is contained in:
@@ -23,7 +23,7 @@ import {
|
||||
} from './componentProps'
|
||||
import { Slots, initSlots, InternalSlots } from './componentSlots'
|
||||
import { warn } from './warning'
|
||||
import { ErrorCodes, callWithAsyncErrorHandling } from './errorHandling'
|
||||
import { ErrorCodes, callWithErrorHandling, handleError } from './errorHandling'
|
||||
import { AppContext, createAppContext, AppConfig } from './apiCreateApp'
|
||||
import { Directive, validateDirectiveName } from './directives'
|
||||
import {
|
||||
@@ -579,7 +579,7 @@ function setupStatefulComponent(
|
||||
|
||||
currentInstance = instance
|
||||
pauseTracking()
|
||||
const setupResult = callWithAsyncErrorHandling(
|
||||
const setupResult = callWithErrorHandling(
|
||||
setup,
|
||||
instance,
|
||||
ErrorCodes.SETUP_FUNCTION,
|
||||
@@ -591,9 +591,13 @@ function setupStatefulComponent(
|
||||
if (isPromise(setupResult)) {
|
||||
if (isSSR) {
|
||||
// return the promise so server-renderer can wait on it
|
||||
return setupResult.then((resolvedResult: unknown) => {
|
||||
handleSetupResult(instance, resolvedResult, isSSR)
|
||||
})
|
||||
return setupResult
|
||||
.then((resolvedResult: unknown) => {
|
||||
handleSetupResult(instance, resolvedResult, isSSR)
|
||||
})
|
||||
.catch(e => {
|
||||
handleError(e, instance, ErrorCodes.SETUP_FUNCTION)
|
||||
})
|
||||
} else if (__FEATURE_SUSPENSE__) {
|
||||
// async setup returned Promise.
|
||||
// bail here and wait for re-entry.
|
||||
|
||||
Reference in New Issue
Block a user