@@ -2,7 +2,7 @@ import { pauseTracking, resetTracking } from '@vue/reactivity'
22import type { VNode } from './vnode'
33import type { ComponentInternalInstance } from './component'
44import { popWarningContext , pushWarningContext , warn } from './warning'
5- import { isFunction , isPromise } from '@vue/shared'
5+ import { isArray , isFunction , isPromise } from '@vue/shared'
66import { LifecycleHooks } from './enums'
77
88// contexts where user provided function may be executed, in addition to
@@ -79,7 +79,7 @@ export function callWithAsyncErrorHandling(
7979 instance : ComponentInternalInstance | null ,
8080 type : ErrorTypes ,
8181 args ?: unknown [ ] ,
82- ) : any [ ] {
82+ ) : any {
8383 if ( isFunction ( fn ) ) {
8484 const res = callWithErrorHandling ( fn , instance , type , args )
8585 if ( res && isPromise ( res ) ) {
@@ -90,11 +90,17 @@ export function callWithAsyncErrorHandling(
9090 return res
9191 }
9292
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+ )
96103 }
97- return values
98104}
99105
100106export function handleError (
0 commit comments