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): prevent errors when backwards compat node.nodeId is for a deleted node in touchNode #29575

Merged
merged 3 commits into from
Feb 19, 2021

Conversation

TylerBarnes
Copy link
Contributor

With the v3 change to touchNode, a subtle bug was introduced - previously calling touchNode on an id for a node that no longer exists worked fine, now Gatsby will throw errors about accessing id on undefined. This PR accounts for that situation 👍

@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Feb 18, 2021
@TylerBarnes TylerBarnes removed the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Feb 18, 2021
@TylerBarnes TylerBarnes requested a review from vladar February 18, 2021 19:43
@TylerBarnes TylerBarnes changed the title fix(gatsby): prevent errors when backwards compat node.nodeId is for a deleted node fix(gatsby): prevent errors when backwards compat node.nodeId is for a deleted node in touchNode Feb 18, 2021
Copy link
Contributor

@vladar vladar left a comment

Choose a reason for hiding this comment

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

Do we still need to dispatch this action if there is no node? Maybe try returning an empty array and do not dispatch the action at all (we do something similar here):

actions.createServerVisitedPage = (chunkName: string) => {
if (store.getState().visitedPages.get(`server`)?.has(chunkName)) {
// we already have given chunk tracked, let's not emit `CREATE_SERVER_VISITED_PAGE`
// action to not cause any additional work
return []
}

Copy link
Contributor

@vladar vladar left a comment

Choose a reason for hiding this comment

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

Thanks 🙏

@vladar vladar added the bot: merge on green Gatsbot will merge these PRs automatically when all tests passes label Feb 19, 2021
@gatsbybot gatsbybot merged commit 077eb16 into master Feb 19, 2021
@gatsbybot gatsbybot deleted the fix/new-touch-node-deleted-node-id branch February 19, 2021 07:16
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.

3 participants