Stale artifacts after interrupted Hardhat compilation
0 reputation · 20 Dec 2021, 17:39 UTC
Goal
Determine whether Hardhat guarantees mutual consistency between the artifacts/ compilation outputs and cache/ incremental-build metadata after a failed compile, process interruption, or concurrent invocation.
Hardhat writes ABI and bytecode artifacts to artifacts/ and records source and import-graph content hashes in cache/. On a failed compile, the failing contract keeps its previous artifact instead of partial output, and unchanged contracts retain earlier artifacts. Both directories are build outputs, but no documented atomic-write guarantee covers them together across failures or concurrent runs.
This uncertainty applies to Hardhat versions without a documented atomic-write guarantee for artifacts/ and cache/. A stale artifact could remain alongside a newer cache entry, or vice versa, without an obvious signal.
- Does Hardhat guarantee that artifacts/ and cache/ stay consistent after a failed or interrupted compilation?
- Can a concurrent Hardhat invocation leave a stale artifact paired with an updated cache entry?
- What build-info comparison detects divergence between artifacts/ and cache/ after a failure?