Skip to content

Cleanup non-deterministic app directory files for pnpm#1321

Merged
colincasey merged 3 commits intomainfrom
cleanup-pnpm-modules-yaml
Mar 5, 2026
Merged

Cleanup non-deterministic app directory files for pnpm#1321
colincasey merged 3 commits intomainfrom
cleanup-pnpm-modules-yaml

Conversation

@colincasey
Copy link
Copy Markdown
Contributor

@colincasey colincasey commented Mar 4, 2026

Summary

  • Removes pnpm's node_modules/.modules.yaml after install — contains a prunedAt timestamp that changes every build
  • Refactors cleanup system: replaces LayerCleanupTarget/LayerKind with CleanupTask enum and NodeGypArtifactLocation
  • Moves cleanup orchestration from main.rs into cleanup::run_post_build_cleanup_tasks()
  • Narrows Makefile removal filter to only match files within node_modules/ directories
  • Updates all affected snapshots

Root Cause

pnpm writes a prunedAt timestamp to node_modules/.modules.yaml on every install, causing the CNB lifecycle to detect workspace changes and report Added instead of Reused for the app layer on rebuild. pnpm regenerates this file on every install so it is safe to remove.

Test plan

  • cargo clippy --all-targets --locked -- --deny warnings passes
  • cargo test unit tests pass (84 tests including new tests for .modules.yaml removal and node_modules ancestor filtering)
  • All rebuild snapshots verified: native module rebuild tests show Reused on rebuild
  • CI passes

Stacked on #1319.

W-21433567

@colincasey colincasey self-assigned this Mar 4, 2026
@colincasey colincasey requested a review from a team March 4, 2026 19:30
@edmorley edmorley removed the request for review from a team March 4, 2026 19:34
@colincasey colincasey marked this pull request as ready for review March 4, 2026 19:50
@colincasey colincasey requested a review from a team as a code owner March 4, 2026 19:50
Base automatically changed from cleanup-yarn-app-dir-artifacts to main March 5, 2026 15:11
pnpm writes a `prunedAt` timestamp to `node_modules/.modules.yaml`
on every install, causing non-deterministic app layer content in
the CNB lifecycle. Since pnpm regenerates this file on every install,
it is safe to remove during cleanup.

W-21433567
Removes pnpm's .modules.yaml from node_modules/ after install. This
file contains a prunedAt timestamp that changes on every install,
causing non-deterministic app layer content. pnpm regenerates this
file on every install so it is safe to remove.

Also refactors the cleanup system: replaces LayerCleanupTarget/LayerKind
with a CleanupTask enum, moves the cleanup loop into cleanup.rs, and
narrows the Makefile filter to only match within node_modules directories.

W-21433567
@colincasey colincasey force-pushed the cleanup-pnpm-modules-yaml branch from 1f22ce7 to ee23baa Compare March 5, 2026 15:13
@colincasey colincasey enabled auto-merge (squash) March 5, 2026 15:14
@colincasey colincasey merged commit 3773515 into main Mar 5, 2026
7 checks passed
@colincasey colincasey deleted the cleanup-pnpm-modules-yaml branch March 5, 2026 15:26
heroku-linguist bot added a commit that referenced this pull request Mar 5, 2026
## heroku/nodejs

### Fixed

- Fixed non-deterministic app layer caching when native modules are compiled by npm or yarn. ([#1317](#1317))
- Fixed non-deterministic app layer caching when native modules are compiled by yarn with PnP linker. ([#1319](#1319))
- Fixed non-deterministic app layer caching caused by pnpm's `.modules.yaml` timestamp. ([#1321](#1321))

### Added

- 25.8.0 (linux-amd64, linux-arm64)
- 22.22.1 (linux-amd64, linux-arm64)
- 20.20.1 (linux-amd64, linux-arm64)
@heroku-linguist heroku-linguist bot mentioned this pull request Mar 5, 2026
heroku-linguist bot added a commit that referenced this pull request Mar 5, 2026
## heroku/nodejs

### Fixed

- Fixed non-deterministic app layer caching when native modules are compiled by npm or yarn. ([#1317](#1317))
- Fixed non-deterministic app layer caching when native modules are compiled by yarn with PnP linker. ([#1319](#1319))
- Fixed non-deterministic app layer caching caused by pnpm's `.modules.yaml` timestamp. ([#1321](#1321))

### Added

- 25.8.0 (linux-amd64, linux-arm64)
- 22.22.1 (linux-amd64, linux-arm64)
- 20.20.1 (linux-amd64, linux-arm64)

Co-authored-by: heroku-linguist[bot] <136119646+heroku-linguist[bot]@users.noreply.github.com>
heroku-linguist bot added a commit to heroku/cnb-builder-images that referenced this pull request Mar 5, 2026
## heroku/nodejs

### Fixed

- Fixed non-deterministic app layer caching when native modules are compiled by npm or yarn. ([#1317](heroku/buildpacks-nodejs#1317))
- Fixed non-deterministic app layer caching when native modules are compiled by yarn with PnP linker. ([#1319](heroku/buildpacks-nodejs#1319))
- Fixed non-deterministic app layer caching caused by pnpm's `.modules.yaml` timestamp. ([#1321](heroku/buildpacks-nodejs#1321))

### Added

- 25.8.0 (linux-amd64, linux-arm64)
- 22.22.1 (linux-amd64, linux-arm64)
- 20.20.1 (linux-amd64, linux-arm64)
heroku-linguist bot added a commit to heroku/cnb-builder-images that referenced this pull request Mar 5, 2026
## heroku/nodejs

### Fixed

- Fixed non-deterministic app layer caching when native modules are compiled by npm or yarn. ([#1317](heroku/buildpacks-nodejs#1317))
- Fixed non-deterministic app layer caching when native modules are compiled by yarn with PnP linker. ([#1319](heroku/buildpacks-nodejs#1319))
- Fixed non-deterministic app layer caching caused by pnpm's `.modules.yaml` timestamp. ([#1321](heroku/buildpacks-nodejs#1321))

### Added

- 25.8.0 (linux-amd64, linux-arm64)
- 22.22.1 (linux-amd64, linux-arm64)
- 20.20.1 (linux-amd64, linux-arm64)

Co-authored-by: heroku-linguist[bot] <136119646+heroku-linguist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants