From 37cdcdcae2476fca06293b112c0e8e5d2df8d9f5 Mon Sep 17 00:00:00 2001 From: OlegIvaniv Date: Thu, 30 Mar 2023 13:29:36 +0200 Subject: [PATCH] fix(core): Do not user `util.types.isProxy` for tracking of augmented objects (#5836) --- 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