Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restructure Graph - separate traversal from state mutation
Summary: This is a significant restructuring of the internal operation of `Graph`. Currently, we asynchronously traverse, and resolve, from a set of entry/modified paths, updating the graph's state as we go. This change performs the same work in two distinct phases: 1. Draft: Asynchronously traverse the necessary modules, collecting transform and resolution results with *no* mutation - using a separate, ephemeral `GraphTraversal` instance to make that explicit. 2. Commit: Mutate graph state in a second, synchronous, depth-first traversal of the modified modules. The motivation for this is twofold: - Resolve a category of known bugs where a userland issue, such as a syntax error or unresolvable dependency, would interrupt traversal and potentially leave internal state *partially* updated *without sending an update to the client*. This will now fail in the draft phase, allowing `DeltaCalculator` to repeat the attempt when the userland issue is fixed. - Makes the operation of `Graph` easier to reason about, and opens up several opportunities for simplification (to follow). For example, the commit phase being synchronous means that ordering is deterministic, and that the need to track `earlyInverseDependencies` is obviated. Some of the issues fixed here were introduced by Graph delta pruning in D45691844, but others are longstanding. New unit tests cover the major cases. Changelog: ``` **[Fix]**: Fast Refresh may fail or lose modifications after correcting transform or resolution issues in user code. ``` Reviewed By: motiz88 Differential Revision: D51665495 fbshipit-source-id: 0bd45c6e56d148fcc64bca60cd86ed6034b8034d
- Loading branch information