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