Skip to content

[Bug]: Persistent cache fully invalidated when switching between build and serve with the same config #13098

@Armine-i

Description

@Armine-i

System Info

System:
OS: macOS (Darwin 25.2.0)
CPU: ARM64 (Apple Silicon)

Binaries:
Node: v24.12.0
npm: 11.10.0

NPM packages:
@rspack/cli: ^1.7.6
@rspack/core: ^1.7.6

Details

When using experiments.cache with type: 'persistent', switching between rspack build and rspack serve using the same config file causes the entire persistent cache to be invalidated and rewritten. No module-level build artifacts are reused, even though the config file, loaders, and source files are identical.

Partial cache validation is supported in Webpack 5's filesystem cache and we currently benefit a great deal from it. This is a blocker for a workflow we rely on in our large codebase: CI runs rspack build to produce a warm persistent cache, and that cache is shipped to other environments such as remote developer environments so developers benefit from it on their first rspack serve cold start.

Reproduce link

https://github.com/Armine-i/rspack-repro/tree/mina-repro

Reproduce Steps

  1. Run rspack build -c rspack/rspack.config.ts: cache is created under a single hash folder
  2. Run rspack serve -c rspack/rspack.config.ts: the same hash folder's contents are fully invalidated and rewritten
  3. Run rspack build -c rspack/rspack.config.ts again: fully invalidated and rewritten again

Each switch between build and serve produces a cache miss despite no source files or config changing.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions