Cleanup non-deterministic app directory files for pnpm#1321
Merged
colincasey merged 3 commits intomainfrom Mar 5, 2026
Merged
Conversation
edmorley
approved these changes
Mar 4, 2026
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
1f22ce7 to
ee23baa
Compare
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)
Merged
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
node_modules/.modules.yamlafter install — contains aprunedAttimestamp that changes every buildLayerCleanupTarget/LayerKindwithCleanupTaskenum andNodeGypArtifactLocationmain.rsintocleanup::run_post_build_cleanup_tasks()node_modules/directoriesRoot Cause
pnpm writes a
prunedAttimestamp tonode_modules/.modules.yamlon every install, causing the CNB lifecycle to detect workspace changes and reportAddedinstead ofReusedfor 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 warningspassescargo testunit tests pass (84 tests including new tests for.modules.yamlremoval andnode_modulesancestor filtering)Reusedon rebuildStacked on #1319.
W-21433567