module: add a read-only mode to the compile cache - #65302
Open
codebytere wants to merge 1 commit into
Open
Conversation
Collaborator
|
Review requested:
|
codebytere
force-pushed
the
compile-cache-read-only
branch
2 times, most recently
from
August 15, 2026 09:09
447fb62 to
133e37b
Compare
codebytere
force-pushed
the
compile-cache-read-only
branch
from
August 16, 2026 18:30
133e37b to
d57ec48
Compare
A compile cache generated ahead of time and shipped inside an application package should only ever be read: the package may be immutable or covered by an integrity check, and a cache directory that appears at run time would be a surprise. Add readOnly to module.enableCompileCache() and NODE_COMPILE_CACHE_READONLY=1: existing entries are loaded as before, nothing is serialized or persisted, flushCompileCache() is a no-op, and the cache directory is used as found rather than created, so enabling against a missing directory fails instead of making one. Signed-off-by: Shelley Vohr <shelley.vohr@gmail.com>
codebytere
force-pushed
the
compile-cache-read-only
branch
from
August 16, 2026 18:31
d57ec48 to
dc597d8
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #65302 +/- ##
==========================================
- Coverage 90.32% 90.13% -0.20%
==========================================
Files 751 752 +1
Lines 249960 251615 +1655
Branches 47204 47269 +65
==========================================
+ Hits 225774 226783 +1009
- Misses 15564 16174 +610
- Partials 8622 8658 +36
🚀 New features to boost your workflow:
|
jasnell
approved these changes
Aug 17, 2026
Collaborator
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.
A compile cache generated ahead of time and shipped inside an application package should only ever be read: the package may be immutable (an Electron
app.asar, a read-only image) or covered by an integrity check, and a cache directory that appears at run time next to shipped code is a surprise either way. Today enabling the cache always implies writing: the tag directory is created on enable, and every module without an accepted entry is serialized and persisted at exit or onflushCompileCache().This adds
readOnlytomodule.enableCompileCache()andNODE_COMPILE_CACHE_READONLY=1. With it, existing entries are looked up and loaded exactly as before; nothing is serialized into the in-memory store or written to disk,flushCompileCache()is a no-op, the write-permission check is skipped, and the cache directory is used as found rather than created, so enabling against a directory that does not exist fails (FAILED, with a message) instead of making one.EnableOptionbecomes a small flag set (PORTABLE,READ_ONLY) since the two combine. Docs cover the option, the environment variable (cli.md, node.1) and a short section in module.md;test-compile-cache-api-readonlycovers the missing-directory case, reading a previously generated cache without writing new entries, and the environment variable.Context: same application as #65293 (an Electron app shipping its main-process cache in the package); review there asked that production launches never attempt writes.