Skip to content

fix: select NODE_OPTIONS constant by NUL-termination (fixes win-x64 / node 24)#33

Merged
BYK merged 1 commit into
mainfrom
fix/ignore-node-options-windows
Jun 11, 2026
Merged

fix: select NODE_OPTIONS constant by NUL-termination (fixes win-x64 / node 24)#33
BYK merged 1 commit into
mainfrom
fix/ignore-node-options-windows

Conversation

@BYK

@BYK BYK commented Jun 11, 2026

Copy link
Copy Markdown
Owner

Problem

--ignore-node-options (0.10.0) located the NODE_OPTIONS lookup constant by
requiring it to be NUL-bounded (\0NODE_OPTIONS\0). That holds for node-v22
on most platforms, but with the MSVC linker (Windows) and node-v24 the getenv
argument is suffix-pooled into the … is not allowed in NODE_OPTIONS error
string, so it is preceded by text, not a NUL.

Result: fossilize threw Could not find the NODE_OPTIONS lookup constant and
failed the win-x64 build when nodeVersion: lts resolved to 24.16.0 (seen
in a downstream consumer's CI).

Fix

Relax the selector to require only NUL-termination (a real C string) plus
printable-ASCII/NUL surroundings:

  • still excludes the JS copies (followed by '/)) and the checksummed V8
    startup-snapshot copies (non-printable neighbours);
  • now also matches the suffix-pooled Windows constant;
  • may additionally match a harmless error string ending in NODE_OPTIONS
    patching that too is safe (it's only shown for a flag we now ignore).

All matches are patched.

Verification

Confirmed neutralizeNodeOptions patches the lookup constant (no throw) and
that the resulting binary ignores NODE_OPTIONS on official node-v22.14.0
and node-v24.16.0
× darwin-arm64, linux-x64, linux-arm64, win-x64. The CI
--ignore-node-options step now builds with -n lts to exercise the newest
Node layout.

…nding

The `--ignore-node-options` patch (0.10.0) located the `NODE_OPTIONS` lookup
constant by requiring it to be NUL-bounded (`\0NODE_OPTIONS\0`). That holds for
node-v22 on most platforms, but with the MSVC linker on Windows (and node-v24)
the `getenv` argument is suffix-pooled into the "… is not allowed in
NODE_OPTIONS" error string, so it is preceded by text, not a NUL. As a result
fossilize threw "Could not find the NODE_OPTIONS lookup constant" and failed
the win-x64 build with `nodeVersion: lts` (24.16.0).

Relax the selector to require only NUL-*termination* (a real C string) plus
printable-ASCII/NUL surroundings. This still excludes the JS copies (followed
by `'`/`)`) and the checksummed V8 snapshot copies (non-printable neighbours),
and now also matches the suffix-pooled Windows constant. It may additionally
match a harmless error-message string ending in `NODE_OPTIONS`; patching that
too is safe. All matches are patched.

Verified to neutralize NODE_OPTIONS on official node-v22.14.0 and node-v24.16.0
darwin-arm64, linux-x64, linux-arm64 and win-x64. The CI step now builds with
`-n lts` to exercise the newest Node layout.
@BYK BYK merged commit 46a5383 into main Jun 11, 2026
5 checks passed
@BYK BYK deleted the fix/ignore-node-options-windows branch June 11, 2026 19:46
@craft-deployer craft-deployer Bot mentioned this pull request Jun 11, 2026
2 tasks
BYK added a commit to getsentry/cli that referenced this pull request Jun 11, 2026
… cache valid (#1092)

## Problem

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`, common in JS toolchains),
those flags
change V8's `FlagList::Hash()` at runtime, so V8 rejects the build-time
code
cache and prints `Warning: Code cache data rejected` (then recompiles).

## Fix

- Bump `fossilize` `^0.8.1` → `^0.10.1`.
- Pass `--ignore-node-options` to the fossilize invocation in
`script/build.ts`.

fossilize patches the binary to ignore `NODE_OPTIONS` (equivalent to
building
Node with `--without-node-options`): it renames the `.rodata`
`NODE_OPTIONS`
lookup constant so `getenv()` returns null and no V8 flags are applied.
The
runtime flag-hash then matches the build-time default and the embedded
code
cache is accepted (kept; not disabled).

`process.env` is untouched, so `process.env.NODE_OPTIONS` stays set and
any
child 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_VERSION` is `lts` = 24.x).

## Notes

- Only host-platform (linux-x64, built on ubuntu) currently embeds a
code
  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.
- Typecheck + Biome lint clean; lockfile change is fossilize-only.
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.

1 participant