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

Ignore errors in unreachable modules #1164

Closed
wants to merge 1 commit into from

Conversation

robhogan
Copy link
Contributor

@robhogan robhogan commented Jan 2, 2024

Summary:
Currently, if Metro encounters an error resolving a dependency or transforming a module that is present in the graph at the time the error is introduced, it will return the error to the client and continue to do so, even after the bad dependency is subsequently made unreachable by another change.

This is "fixed" by a full refresh or Metro restart, because a new traversal would not encounter the error, and is therefore a correctness bug.

This diff fixes the bug by:

  • Collecting, instead of immediately throwing on, transform and resolution errors during buildSubgraph (prior to any state modification).
  • If there are errors, take a snapshot of all of the modified modules at the base state.
  • Commit removals only, skipping modified modules with errors, and collect cycles (the "subtractive pass") - this should never fail.
  • Try to commit new and modified dependencies starting from the modified modules still present in the graph (the "additive pass"). Any error caught here corresponds to a reachable error the user must action.
  • On catching an error, commit the base state we captured earlier, rolling the graph back, and re-throw the error.

Changelog:

**[Fix]**: Ignore errors in unreachable modules during incremental builds.

Reviewed By: motiz88

Differential Revision: D52457312

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 2, 2024
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D52457312

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D52457312

Summary:

Currently, if Metro encounters an error resolving a dependency or transforming a module that is present in the graph at the time the error is introduced, it will return the error to the client *and continue to do so, even after the bad dependency is subsequently made unreachable by another change*.

This is "fixed" by a full refresh or Metro restart, because a new traversal would not encounter the error, and is therefore a correctness bug.

This diff fixes the bug by:
 - Collecting, instead of immediately throwing on, transform and resolution errors during `buildSubgraph` (prior to any state modification).
 - If there are errors, take a snapshot of all of the modified modules at the base state.
 - Commit *removals only*, skipping modified modules with errors, and collect cycles (the "subtractive pass") - this should never fail.
 - Try to commit new and modified dependencies starting from the modified modules still present in the graph (the "additive pass"). Any error caught here corresponds to a reachable error the user must action.
 - On catching an error, commit the base state we captured earlier, rolling the graph back, and re-throw the error.

Changelog:
```
**[Fix]**: Ignore errors in unreachable modules during incremental builds.
```

Reviewed By: motiz88

Differential Revision: D52457312
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D52457312

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 698b13e.

@robhogan robhogan deleted the export-D52457312 branch January 2, 2024 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants