Skip to content

[Bug]: missing snapshot_build recovery keeps stale build-dependency output #14864

Description

@hardfist

Reproduction

Repository: https://github.com/hardfist/rspack-persistent-cache-missing-build-deps-recovery-repro

This is a JavaScript repro using the public compiler API and the published @rspack/core@2.1.4 package:

pnpm install
pnpm repro

The repro uses a loader that reads an external flag.txt file. That file is explicitly listed in cache.buildDependencies, so changing it should invalidate the persistent cache.

Steps:

  1. Build with flag.txt = A.
  2. Remove all records from the snapshot_build scope and recompute its pack integrity hash.
  3. Change flag.txt to B and start a fresh process against the cache.
  4. Compare with a cold build.

Observed on @rspack/core@2.1.4:

recovered exit: 0
recovered output contains A: true
recovered output contains B: false
cold build has errors: false
cold output contains B: true

BUG REPRODUCED: missing build-dependency recovery keeps stale output.

The recovered build succeeds but silently emits the old result even though the explicitly configured build dependency changed.

Expected behavior

An absent/incomplete snapshot_build scope should invalidate the cache or conservatively rerun build-dependency validation. A changed file listed in cache.buildDependencies must not be ignored during persistent-cache recovery.

Environment

  • @rspack/core@2.1.4
  • Node.js 24
  • macOS arm64

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions