refactor: improve persistent cache load error handling#13608
refactor: improve persistent cache load error handling#13608jerrykingxyz merged 3 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Refactors the persistent cache subsystem to make cache load failures safer and more localized by introducing per-scope reset behavior and a shared cache lifecycle context, while removing legacy “artifact state” tracking.
Changes:
- Introduce
CacheContextto centralize persistent cache validity/readonly logic, warning collection, and scoped reset/load/save flows. - Update storage APIs to use synchronous
save()and scopedreset(scope)that enqueue background work, withflush()as the async synchronization point. - Remove
BuildModuleGraphArtifactStateand rely oncompilation.is_rebuildto control persistent-cache recovery behavior.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/rspack_tools/src/compare/occasion/make.rs | Updates imports to use the new Occasion abstraction when recovering make artifacts. |
| crates/rspack_storage/src/memory/mod.rs | Aligns MemoryStorage with new Storage trait (save() and reset(scope)). |
| crates/rspack_storage/src/lib.rs | Changes Storage trait API: save() and scoped reset(scope) become sync enqueue operations. |
| crates/rspack_storage/src/filesystem/mod.rs | Updates filesystem storage implementation to new Storage trait and scoped reset. |
| crates/rspack_storage/src/filesystem/db/mod.rs | Adds scoped DB reset task and readonly fail-safe behavior for background operations. |
| crates/rspack_core/src/compilation/build_module_graph/mod.rs | Stops re-exporting the removed BuildModuleGraphArtifactState. |
| crates/rspack_core/src/compilation/build_module_graph/graph_updater/mod.rs | Removes initialization of the deleted artifact state. |
| crates/rspack_core/src/cache/persistent/snapshot/mod.rs | Adds Snapshot::reset() to clear all snapshot-related scopes. |
| crates/rspack_core/src/cache/persistent/occasion/mod.rs | Introduces the Occasion trait to standardize reset/save/recovery responsibilities. |
| crates/rspack_core/src/cache/persistent/occasion/meta/mod.rs | Converts MetaOccasion to implement the new Occasion trait. |
| crates/rspack_core/src/cache/persistent/occasion/make/mod.rs | Converts MakeOccasion to implement Occasion and removes dependence on artifact state. |
| crates/rspack_core/src/cache/persistent/mod.rs | Reworks PersistentCache to use CacheContext and scoped resets instead of global validity/reset. |
| crates/rspack_core/src/cache/persistent/context.rs | Adds new CacheContext orchestration layer for load/save/reset flows and warning aggregation. |
| crates/rspack_core/src/cache/persistent/build_dependencies/mod.rs | Adds scoped reset for build dependency storage. |
| crates/rspack_core/src/artifacts/build_module_graph_artifact.rs | Removes BuildModuleGraphArtifactState and the state field from the artifact. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8a3c7d789a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Merging this PR will degrade performance by 2.7%
Performance Changes
Comparing Footnotes
|
Rsdoctor Bundle Diff Analysis
Found 6 projects in monorepo, 0 projects with changes. 📊 Quick Summary
Generated by Rsdoctor GitHub Action |
📦 Binary Size-limit
❌ Size increased by 7.91KB from 49.33MB to 49.34MB (⬆️0.02%) |
f58cf34 to
aefba61
Compare
9d2664c to
4a4fce1
Compare
* refactor: remove useless BuildModuleGraphArtifact state * refactor: improve persistent cache load error handling * feat: add trace log in cache context
Summary
Persistent cache loads data for the corresponding Occasion at each runtime stage. This PR improves the error handling process. When an error occurs during loading
Related links
Checklist