@@ -2,7 +2,7 @@ import { pauseTracking, resetTracking } from '@vue/reactivity'
2
2
import type { VNode } from './vnode'
3
3
import type { ComponentInternalInstance } from './component'
4
4
import { popWarningContext , pushWarningContext , warn } from './warning'
5
- import { isFunction , isPromise } from '@vue/shared'
5
+ import { isArray , isFunction , isPromise } from '@vue/shared'
6
6
import { LifecycleHooks } from './enums'
7
7
8
8
// contexts where user provided function may be executed, in addition to
@@ -79,7 +79,7 @@ export function callWithAsyncErrorHandling(
79
79
instance : ComponentInternalInstance | null ,
80
80
type : ErrorTypes ,
81
81
args ?: unknown [ ] ,
82
- ) : any [ ] {
82
+ ) : any {
83
83
if ( isFunction ( fn ) ) {
84
84
const res = callWithErrorHandling ( fn , instance , type , args )
85
85
if ( res && isPromise ( res ) ) {
@@ -90,11 +90,17 @@ export function callWithAsyncErrorHandling(
90
90
return res
91
91
}
92
92
93
- const values = [ ]
94
- for ( let i = 0 ; i < fn . length ; i ++ ) {
95
- values . push ( callWithAsyncErrorHandling ( fn [ i ] , instance , type , args ) )
93
+ if ( isArray ( fn ) ) {
94
+ const values = [ ]
95
+ for ( let i = 0 ; i < fn . length ; i ++ ) {
96
+ values . push ( callWithAsyncErrorHandling ( fn [ i ] , instance , type , args ) )
97
+ }
98
+ return values
99
+ } else if ( __DEV__ ) {
100
+ warn (
101
+ `Invalid value type passed to callWithAsyncErrorHandling(): ${ typeof fn } ` ,
102
+ )
96
103
}
97
- return values
98
104
}
99
105
100
106
export function handleError (
0 commit comments