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 {
35
35
initSlots ,
36
36
} from './componentSlots'
37
37
import { warn } from './warning'
38
- import { ErrorCodes , callWithErrorHandling , handleError } from './errorHandling'
38
+ import {
39
+ ErrorCodes ,
40
+ callWithAsyncErrorHandling ,
41
+ callWithErrorHandling ,
42
+ handleError ,
43
+ } from './errorHandling'
39
44
import {
40
45
type AppConfig ,
41
46
type AppContext ,
@@ -67,6 +72,7 @@ import {
67
72
extend ,
68
73
getGlobalThis ,
69
74
isArray ,
75
+ isAsyncFunction ,
70
76
isFunction ,
71
77
isObject ,
72
78
isPromise ,
@@ -860,15 +866,14 @@ function setupStatefulComponent(
860
866
const setupContext = ( instance . setupContext =
861
867
setup . length > 1 ? createSetupContext ( instance ) : null )
862
868
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
+ ] )
872
877
const isAsyncSetup = isPromise ( setupResult )
873
878
resetTracking ( )
874
879
reset ( )
Original file line number Diff line number Diff line change @@ -48,6 +48,8 @@ export const isRegExp = (val: unknown): val is RegExp =>
48
48
toTypeString ( val ) === '[object RegExp]'
49
49
export const isFunction = ( val : unknown ) : val is Function =>
50
50
typeof val === 'function'
51
+ export const isAsyncFunction = ( val : unknown ) : val is Function =>
52
+ typeof val === 'function' && toTypeString ( val ) === '[object AsyncFunction]'
51
53
export const isString = ( val : unknown ) : val is string => typeof val === 'string'
52
54
export const isSymbol = ( val : unknown ) : val is symbol => typeof val === 'symbol'
53
55
export const isObject = ( val : unknown ) : val is Record < any , any > =>
You can’t perform that action at this time.
0 commit comments