From ae61ea2ac8f71c41b6ba0577518bf4cba565a041 Mon Sep 17 00:00:00 2001 From: Oleg Ivaniv Date: Thu, 30 Mar 2023 12:35:56 +0200 Subject: [PATCH] fix(core): Do not user `util.types.isProxy` for tracking of augmented objects --- packages/workflow/src/AugmentObject.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/workflow/src/AugmentObject.ts b/packages/workflow/src/AugmentObject.ts index a8b29d066c762..a56fd7cb06bcd 100644 --- a/packages/workflow/src/AugmentObject.ts +++ b/packages/workflow/src/AugmentObject.ts @@ -1,15 +1,18 @@ import type { IDataObject } from './Interfaces'; -import util from 'util'; +const augmentedObjects = new WeakSet(); function augment(value: T): T { if ( typeof value !== 'object' || value === null || - util.types.isProxy(value) || - value instanceof RegExp + value instanceof RegExp || + augmentedObjects.has(value) ) return value; + // Track augmented objects to prevent infinite recursion in cases where an object contains circular references + augmentedObjects.add(value); + if (value instanceof Date) return new Date(value.valueOf()) as T; // eslint-disable-next-line @typescript-eslint/no-use-before-define