fix(build): ignore NODE_OPTIONS in the SEA binary to keep the V8 code cache valid#1092
Merged
Conversation
… cache valid The standalone `sentry` binary is a Node SEA with an embedded V8 code cache. When a user has V8 flags in NODE_OPTIONS (e.g. `NODE_OPTIONS=--max-old-space-size=8192`), those flags change V8's FlagList::Hash() at runtime, so V8 rejects the build-time code cache and emits `Warning: Code cache data rejected` (and recompiles). Bump fossilize to ^0.10.1 and pass `--ignore-node-options`, which patches the binary to ignore NODE_OPTIONS (equivalent to `--without-node-options`). The flag-hash then matches the build-time default and the cache is accepted. process.env is untouched, so child processes still inherit NODE_OPTIONS. (0.10.1 also fixes the NODE_OPTIONS-constant selector for win-x64 / node 24.)
Contributor
Codecov Results 📊✅ Patch coverage is 100.00%. Project has 5011 uncovered lines. Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 81.20% 81.20% —%
==========================================
Files 383 383 —
Lines 26649 26649 —
Branches 17340 17340 —
==========================================
+ Hits 21637 21638 +1
- Misses 5012 5011 -1
- Partials 1798 1798 —Generated by Codecov Action |
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.
Problem
The standalone
sentrybinary is a Node SEA with an embedded V8 code cache.When a user has V8 flags in
NODE_OPTIONS(e.g.NODE_OPTIONS=--max-old-space-size=8192, common in JS toolchains), those flagschange V8's
FlagList::Hash()at runtime, so V8 rejects the build-time codecache and prints
Warning: Code cache data rejected(then recompiles).Fix
fossilize^0.8.1→^0.10.1.--ignore-node-optionsto the fossilize invocation inscript/build.ts.fossilize patches the binary to ignore
NODE_OPTIONS(equivalent to buildingNode with
--without-node-options): it renames the.rodataNODE_OPTIONSlookup constant so
getenv()returns null and no V8 flags are applied. Theruntime flag-hash then matches the build-time default and the embedded code
cache is accepted (kept; not disabled).
process.envis untouched, soprocess.env.NODE_OPTIONSstays set and anychild process still inherits the user's flags.
fossilize 0.10.x details: BYK/fossilize#31 (the feature) and BYK/fossilize#33
(NUL-termination selector fix for win-x64 / node 24 — relevant here since
NODE_VERSIONislts= 24.x).Notes
cache; the patch is applied to all targets and is a no-op effect for
cross-compiled ones (just renames the constant), so it's safe everywhere.