Repository navigation
Release shared transform results after failed updates - #2244
Conversation
With `transformer.unstable_shareTransformResults`, `Transformer` drops a shared result once no graph holds it, but only paths that a graph commits get released. A live graph's failed update rolls back, so the graph never holds the modules that update transformed for the first time, and nothing releases them. Eg an edit imports a new file whose own import fails to resolve, then the next edit drops the import: the new file's result stays in memory until something transforms that file again. This PR has `DeltaBundler` record the paths each live graph transforms. A failed update still releases nothing, so what it transformed stays shared with the graph's retries (and with other graphs hitting the same error) while the error persists. Once the graph next commits an update, or ends, it releases the recorded paths it doesn't hold, which drops their results unless another graph holds them. The cost is one `Set` insertion per module that an update transforms, and nothing with sharing off. Graphs that `DeltaBundler` never registers, ie from `getDependencies` or a failed first build, still don't release what they add, which keeps prepended scripts shared. Changelog: Internal Test plan: New unit tests. E2E (AI-driven): an `IncrementalBundler` with sharing on, watching a fixture. An edit imported a new file that failed to resolve its own import, so the update failed. A second edit dropped the import and the update succeeded. Building a graph of the new file then read its result from the cache store once with this PR, and not at all before it, because the shared result was still held.
2d5e1a4 to
32bb61f
Compare
Metro review: Looks goodRisk: low · Commit: With No findings. Verified
Not run: No benchmark. The extra work is one Automated review by Claude. Advisory only: it never approves or blocks, and a maintainer makes the call. |
With
transformer.unstable_shareTransformResults, a shared result is dropped once no graph holds it, but only paths that a graph commits get released. A live graph's failed update rolls back, so the graph never holds the modules that update transformed for the first time, and nothing releases them.This change
DeltaBundlernow records the paths each live graph transforms, and releases the ones it doesn't hold once the graph commits an update or ends. A failed update still releases nothing, so its results stay shared with the graph's retries, and with other graphs hitting the same error, while the error lasts.The cost is one
Setinsertion per module that an update transforms, and nothing with sharing off.Graphs that
DeltaBundlernever registers, ie fromgetDependenciesor a failed first build, still don't release what they add, which keeps prepended scripts shared.Changelog: Internal
Test plan
New unit tests.
E2E (AI-driven): an
IncrementalBundlerwith sharing on, watching a fixture, ran the edits in the diagram. Building a graph of the new file afterwards read it from the cache store once with this PR, and not at all onmain, where the shared result was still held.