Skip to content

Commit 53d15d3

Browse files
authored
fix(runtime-core): handle invalid values in callWithAsyncErrorHandling
1 parent 7ccd453 commit 53d15d3

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

packages/runtime-core/src/errorHandling.ts

+12-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { pauseTracking, resetTracking } from '@vue/reactivity'
22
import type { VNode } from './vnode'
33
import type { ComponentInternalInstance } from './component'
44
import { popWarningContext, pushWarningContext, warn } from './warning'
5-
import { isFunction, isPromise } from '@vue/shared'
5+
import { isArray, isFunction, isPromise } from '@vue/shared'
66
import { 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

100106
export function handleError(

0 commit comments

Comments
 (0)