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(gatsby): Sanitize length on objects #34253

Merged
merged 7 commits into from
Nov 24, 2022

Conversation

iChenLei
Copy link
Contributor

@iChenLei iChenLei commented Dec 14, 2021

Description

Fix #26565

Documentation

N/A

Related Issues

lodash/lodash#2352

@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Dec 14, 2021
@@ -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
Copy link
Contributor Author

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.

@LekoArts LekoArts added topic: remark/mdx Related to Markdown, remark & MDX ecosystem and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Jan 25, 2022
Copy link
Contributor

@LekoArts LekoArts left a 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

@LekoArts LekoArts changed the title fix(gatsby-transformer-remark): allow frontmatter inlcude length field fix(gatsby): Sanitize length on objects Nov 24, 2022
@LekoArts LekoArts merged commit 0889d31 into gatsbyjs:master Nov 24, 2022
@iChenLei iChenLei deleted the fix-frontmatter-length branch November 25, 2022 01:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: remark/mdx Related to Markdown, remark & MDX ecosystem
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[gatsby-transformer-remark] Including length in frontmatter may cause heap out of memory
2 participants