File tree Expand file tree Collapse file tree 2 files changed +17
-10
lines changed
Expand file tree Collapse file tree 2 files changed +17
-10
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,12 @@ import {
3535 initSlots ,
3636} from './componentSlots'
3737import { warn } from './warning'
38- import { ErrorCodes , callWithErrorHandling , handleError } from './errorHandling'
38+ import {
39+ ErrorCodes ,
40+ callWithAsyncErrorHandling ,
41+ callWithErrorHandling ,
42+ handleError ,
43+ } from './errorHandling'
3944import {
4045 type AppConfig ,
4146 type AppContext ,
@@ -67,6 +72,7 @@ import {
6772 extend ,
6873 getGlobalThis ,
6974 isArray ,
75+ isAsyncFunction ,
7076 isFunction ,
7177 isObject ,
7278 isPromise ,
@@ -860,15 +866,14 @@ function setupStatefulComponent(
860866 const setupContext = ( instance . setupContext =
861867 setup . length > 1 ? createSetupContext ( instance ) : null )
862868 const reset = setCurrentInstance ( instance )
863- const setupResult = callWithErrorHandling (
864- setup ,
865- instance ,
866- ErrorCodes . SETUP_FUNCTION ,
867- [
868- __DEV__ ? shallowReadonly ( instance . props ) : instance . props ,
869- setupContext ,
870- ] ,
871- )
869+ const setupResult = (
870+ isAsyncFunction ( setup )
871+ ? callWithAsyncErrorHandling
872+ : callWithErrorHandling
873+ ) ( setup , instance , ErrorCodes . SETUP_FUNCTION , [
874+ __DEV__ ? shallowReadonly ( instance . props ) : instance . props ,
875+ setupContext ,
876+ ] )
872877 const isAsyncSetup = isPromise ( setupResult )
873878 resetTracking ( )
874879 reset ( )
Original file line number Diff line number Diff line change @@ -48,6 +48,8 @@ export const isRegExp = (val: unknown): val is RegExp =>
4848 toTypeString ( val ) === '[object RegExp]'
4949export const isFunction = ( val : unknown ) : val is Function =>
5050 typeof val === 'function'
51+ export const isAsyncFunction = ( val : unknown ) : val is Function =>
52+ typeof val === 'function' && toTypeString ( val ) === '[object AsyncFunction]'
5153export const isString = ( val : unknown ) : val is string => typeof val === 'string'
5254export const isSymbol = ( val : unknown ) : val is symbol => typeof val === 'symbol'
5355export const isObject = ( val : unknown ) : val is Record < any , any > =>
You can’t perform that action at this time.
0 commit comments