Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

cloneDeep throws RangeError for Sets with circular references #3122

Copy link
Copy link
Closed
@ajgreenb

Description

@ajgreenb
Issue body actions

If you have an Object containing a Set with a reference to the Object and you _.cloneDeep it, you get RangeError: Maximum call stack size exceeded. In the same situation, but with an Array instead of a Set, there's no problem. Here's how you can reproduce it:

var objSet = { x: new Set() };
objSet.x.add(objSet);
_.cloneDeep(objSet);
// RangeError: Maximum call stack size exceeded

var objArr = { x: [] };
objArr.x.push(objArr);
_.cloneDeep(objArr);
// Properly deep-cloned object

Seems like circular dependencies aren't properly handled when they're in Sets? From #2137 I saw that support for deep-cloning Sets, Maps, and Symbols was added at 24cef1a. Is this behavior expected? If not, I'd be happy to attempt a fix. Seems like I would need to patch the baseClone function?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.