-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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(gatsby): Sanitize length
on objects
#34253
Conversation
@@ -14,6 +14,16 @@ const sanitizeNode = (data, isNode = true, path = new Set()) => { | |||
path.add(data) | |||
|
|||
const returnData = isPlainObject ? {} : [] | |||
// Refer to https://github.com/gatsbyjs/gatsby/issues/26565 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_.each is work for both arrary
and object
and show high performance, so that's why gatsbyjs use it at here. For preventing OOM
when we use _.each
to loop { length: SUPER_MAX_INTEGER, ... }
object, we also can refact these code to Object.keys
or other implemention. It's depends on the opinion of the gatsby team.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks 👍 The file was since then moved to TS so I refactored a bit and added a unit test. Functionality is the same as yours
length
fieldlength
on objects
Description
Fix #26565
Documentation
N/A
Related Issues
lodash/lodash#2352