From 588bcf74ac5d1dace80f16e89e59c7d3cd85ba6e Mon Sep 17 00:00:00 2001 From: smallnine Date: Mon, 2 Jan 2023 16:21:31 +0800 Subject: [PATCH 1/2] fix(runtime-core): Infinite Loop Detection should throw a real error (close #7437) --- packages/runtime-core/src/scheduler.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/runtime-core/src/scheduler.ts b/packages/runtime-core/src/scheduler.ts index 5b096b563e4..67f2294b44d 100644 --- a/packages/runtime-core/src/scheduler.ts +++ b/packages/runtime-core/src/scheduler.ts @@ -1,7 +1,6 @@ import { ErrorCodes, callWithErrorHandling } from './errorHandling' import { Awaited, isArray, NOOP } from '@vue/shared' import { ComponentInternalInstance, getComponentName } from './component' -import { warn } from './warning' export interface SchedulerJob extends Function { id?: number @@ -271,7 +270,7 @@ function checkRecursiveUpdates(seen: CountMap, fn: SchedulerJob) { if (count > RECURSION_LIMIT) { const instance = fn.ownerInstance const componentName = instance && getComponentName(instance.type) - warn( + throw new Error( `Maximum recursive updates exceeded${ componentName ? ` in component <${componentName}>` : `` }. ` + From c5cae4cf6db8a48c5e8fb00f09825f50f2f8c6a9 Mon Sep 17 00:00:00 2001 From: smallnine Date: Tue, 3 Jan 2023 01:36:26 +0800 Subject: [PATCH 2/2] fix(runtime-core): Using handleError instead, not throwing error --- packages/runtime-core/src/scheduler.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/runtime-core/src/scheduler.ts b/packages/runtime-core/src/scheduler.ts index 67f2294b44d..0b317581063 100644 --- a/packages/runtime-core/src/scheduler.ts +++ b/packages/runtime-core/src/scheduler.ts @@ -1,4 +1,4 @@ -import { ErrorCodes, callWithErrorHandling } from './errorHandling' +import { ErrorCodes, callWithErrorHandling, handleError } from './errorHandling' import { Awaited, isArray, NOOP } from '@vue/shared' import { ComponentInternalInstance, getComponentName } from './component' @@ -270,14 +270,16 @@ function checkRecursiveUpdates(seen: CountMap, fn: SchedulerJob) { if (count > RECURSION_LIMIT) { const instance = fn.ownerInstance const componentName = instance && getComponentName(instance.type) - throw new Error( + handleError( `Maximum recursive updates exceeded${ componentName ? ` in component <${componentName}>` : `` }. ` + `This means you have a reactive effect that is mutating its own ` + `dependencies and thus recursively triggering itself. Possible sources ` + `include component template, render function, updated hook or ` + - `watcher source function.` + `watcher source function.`, + null, + ErrorCodes.APP_ERROR_HANDLER ) return true } else {