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): Fix stack overflow on queries with circular fragments #20936

Merged
merged 3 commits into from
Jan 28, 2020

Conversation

vladar
Copy link
Contributor

@vladar vladar commented Jan 28, 2020

Description

This PR fixes stack overflow caused by circular fragments. Stack overflow was first introduced here: #19665

Related Issues

Fixes #20826

@vladar vladar marked this pull request as ready for review January 28, 2020 08:16
@vladar vladar requested a review from a team as a code owner January 28, 2020 08:16
@vladar vladar requested a review from freiksenet January 28, 2020 08:17
@vladar vladar added the bot: merge on green Gatsbot will merge these PRs automatically when all tests passes label Jan 28, 2020
@gatsbybot gatsbybot merged commit 094ca4c into master Jan 28, 2020
@delete-merged-branch delete-merged-branch bot deleted the vladar/gh-20826 branch January 28, 2020 08:19
Comment on lines +447 to 451
if (visitedFragmentDefinitions.has(fragmentDefinition)) {
return
}
visitedFragmentDefinitions.add(fragmentDefinition)
if (fragmentDefinition) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This implies that you may be adding primitives to the visitedFragmentDefinitions set.

If nothing else, I would bet that we could move the 447-450 to be inside the falsy check to prevent falsy values being added to the queue. Or if the value is never falsy, drop the check.

Also, if name is a unique descriptor of these objects then maybe that would be as good a value to use for this purpose.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, fragmentDefinition can be undefined in an edge case. Will move the check inside if (fragmentDefinition) { }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: merge on green Gatsbot will merge these PRs automatically when all tests passes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fragments referencing each other causes a stack overflow
4 participants