From 968968f730e76de4bd6b64cf09e7cbc6b1b8eddc Mon Sep 17 00:00:00 2001 From: mingrui123 <1529539548@qq.com> Date: Sat, 9 Mar 2024 01:37:06 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20fn=E6=B7=BB=E5=8A=A0=E6=95=B0?= =?UTF-8?q?=E7=BB=84=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/runtime-core/src/errorHandling.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/runtime-core/src/errorHandling.ts b/packages/runtime-core/src/errorHandling.ts index 041eb123938..c764ffe87cf 100644 --- a/packages/runtime-core/src/errorHandling.ts +++ b/packages/runtime-core/src/errorHandling.ts @@ -1,7 +1,7 @@ import type { VNode } from './vnode' import type { ComponentInternalInstance } from './component' import { popWarningContext, pushWarningContext, warn } from './warning' -import { isFunction, isPromise } from '@vue/shared' +import {isArray, isFunction, isPromise} from '@vue/shared' import { LifecycleHooks } from './enums' // contexts where user provided function may be executed, in addition to @@ -90,8 +90,10 @@ export function callWithAsyncErrorHandling( } const values = [] - for (let i = 0; i < fn.length; i++) { - values.push(callWithAsyncErrorHandling(fn[i], instance, type, args)) + if (isArray(fn)) { + for (let i = 0; i < fn.length; i++) { + values.push(callWithAsyncErrorHandling(fn[i], instance, type, args)) + } } return values } From 730c9f61390e5c065422b607627063c5a987e26f Mon Sep 17 00:00:00 2001 From: Evan You Date: Mon, 15 Apr 2024 22:32:54 +0800 Subject: [PATCH 2/3] Update errorHandling.ts --- packages/runtime-core/src/errorHandling.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/runtime-core/src/errorHandling.ts b/packages/runtime-core/src/errorHandling.ts index c764ffe87cf..af796bdcb5e 100644 --- a/packages/runtime-core/src/errorHandling.ts +++ b/packages/runtime-core/src/errorHandling.ts @@ -78,7 +78,7 @@ export function callWithAsyncErrorHandling( instance: ComponentInternalInstance | null, type: ErrorTypes, args?: unknown[], -): any[] { +): any { if (isFunction(fn)) { const res = callWithErrorHandling(fn, instance, type, args) if (res && isPromise(res)) { @@ -89,13 +89,17 @@ export function callWithAsyncErrorHandling( return res } - const values = [] if (isArray(fn)) { + const values = [] for (let i = 0; i < fn.length; i++) { values.push(callWithAsyncErrorHandling(fn[i], instance, type, args)) } + return values + } else if (__DEV__) { + warn( + `Invalid value type passed to callWithAsyncErrorHandling(): ${typeof fn}`, + ) } - return values } export function handleError( From 8d9a7b3bd4150096533f99d74bae9b0fe1f71de1 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Mon, 15 Apr 2024 14:33:45 +0000 Subject: [PATCH 3/3] [autofix.ci] apply automated fixes --- packages/runtime-core/src/errorHandling.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/runtime-core/src/errorHandling.ts b/packages/runtime-core/src/errorHandling.ts index af796bdcb5e..41c92cbd34a 100644 --- a/packages/runtime-core/src/errorHandling.ts +++ b/packages/runtime-core/src/errorHandling.ts @@ -1,7 +1,8 @@ +import { pauseTracking, resetTracking } from '@vue/reactivity' import type { VNode } from './vnode' import type { ComponentInternalInstance } from './component' import { popWarningContext, pushWarningContext, warn } from './warning' -import {isArray, isFunction, isPromise} from '@vue/shared' +import { isArray, isFunction, isPromise } from '@vue/shared' import { LifecycleHooks } from './enums' // contexts where user provided function may be executed, in addition to @@ -133,12 +134,14 @@ export function handleError( // app-level handling const appErrorHandler = instance.appContext.config.errorHandler if (appErrorHandler) { + pauseTracking() callWithErrorHandling( appErrorHandler, null, ErrorCodes.APP_ERROR_HANDLER, [err, exposedInstance, errorInfo], ) + resetTracking() return } }