Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): Do not user util.types.isProxy for tracking of augmented objects #5836

Merged
merged 3 commits into from
Mar 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions packages/workflow/src/AugmentObject.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import type { IDataObject } from './Interfaces';
import util from 'util';

const augmentedObjects = new WeakSet<object>();
function augment<T>(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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will hold on references to these objects forever, and lead to a memory-leak.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nevermind. I forgot that WeakSet would not block the GC.


if (value instanceof Date) return new Date(value.valueOf()) as T;

// eslint-disable-next-line @typescript-eslint/no-use-before-define
Expand Down