Skip to content

Commit

Permalink
Ignore errors in unreachable modules (#1164)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #1164

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

fbshipit-source-id: 6dabb58e6aa899532ffcdd2eea97d4753aa87e21
  • Loading branch information
robhogan authored and facebook-github-bot committed Jan 2, 2024
1 parent add631c commit 698b13e
Show file tree
Hide file tree
Showing 4 changed files with 717 additions and 135 deletions.
Loading

0 comments on commit 698b13e

Please sign in to comment.