10000 cloneDeep throws RangeError for Sets with circular references · Issue #3122 · lodash/lodash · GitHub
[go: up one dir, main page]

Skip to content

cloneDeep throws RangeError for Sets with circular references #3122

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

Closed
ajgreenb opened this issue Apr 24, 2017 · 3 comments · Fixed by #3123
Closed

cloneDeep throws RangeError for Sets with circular references #3122

ajgreenb opened this issue Apr 24, 2017 · 3 comments · Fixed by #3123
Labels

Comments

@ajgreenb
Copy link

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?

@jdalton
Copy link
Member
jdalton commented Apr 24, 2017

Range errors aren't expected so if you're up for making a patch that would rock.

@jdalton
Copy link
Member
jdalton commented Apr 24, 2017

Moved to #3123.

@lock
Copy link
lock bot commented Dec 27, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Dec 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

2 participants
0