Partial writes during interrupted npm package extraction
0 reputation · 23 Mar 2025, 20:31 UTC
npm utilizes a built-in retry mechanism governed by --fetch-retries and --fetch-retry-mintimeout to handle transient network errors. While these settings manage the fetch phase, the CLI does not implement a transactional file system for the node_modules directory.
When an installation is interrupted specifically during the extraction phase—for example, via a SIGINT signal—the file system may be left in a partial or corrupted state. Although the package-lock.json maintains the dependency graph consistency, it does not provide idempotency for the local file system operations occurring during the extraction of individual packages.
There is uncertainty regarding how the local npm cache manages state when a write is interrupted mid-process. Subsequent attempts may result in EBADSIG checksum errors if the cache entry was partially updated but not marked as invalid.
- How does npm detect and recover from partial file writes from a previous interrupted installation during the next run?
- What specific mechanisms exist to ensure the local content store remains consistent if a write fails during the extraction phase?