Skip to content

fix(traverse): only visit paths, not nodes #432

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

Merged
merged 1 commit into from
Feb 13, 2020

Conversation

motiz88
Copy link
Contributor

@motiz88 motiz88 commented Feb 13, 2020

Traversing with visit using a node as the root creates a new NodePath, which detaches the resulting paths from the root File node. I've seen this lead to getFlowType crashing later when it tries to grab the source code from the no-longer-reachable File node[1]. Traversing from a NodePath keeps everything correctly linked and has no downsides AFAICT, so here I changed traverseShallow (which wraps visit) to only accept paths.

[1] I don't have the exact repro case to hand, unfortunately, but this was in the course of working on facebook/react-native-website#1628.

Traversing nodes detaches the resulting paths from the root File node, so they can end up crashing getFlowType which needs to grab the source code from the File.
@danez danez merged commit b34977a into reactjs:master Feb 13, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants