Skip to content

Commit 193a2d7

Browse files
authored
chore(docs): Document how to support a new node version (#21228)
Documents how to add support for a new node version, based on the PRs for Node 26.
1 parent a48e4e9 commit 193a2d7

1 file changed

Lines changed: 107 additions & 0 deletions

File tree

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Supporting a New Node.js Version
2+
3+
_These steps are only relevant to Sentry employees when adding support for a Node.js verison._
4+
5+
Adding support for a new Node version touches three repos.
6+
Because native modules ship precompiled binaries that must be rebuilt for the new Node ABI, the native module repos must be released first, then we bump to the new versions of those in this repo and add the new Node version to the CI matrix.
7+
8+
The order is:
9+
10+
1. [sentry-javascript-profiling-node-binaries](https://github.com/getsentry/sentry-javascript-profiling-node-binaries)
11+
2. [sentry-javascript-node-native-stacktrace](https://github.com/getsentry/sentry-javascript-node-native-stacktrace)
12+
3. [sentry-javascript](https://github.com/getsentry/sentry-javascript)
13+
14+
The Node.js 26 rollout is a good reference:
15+
16+
- Profiling binaries [#32](https://github.com/getsentry/sentry-javascript-profiling-node-binaries/pull/32)
17+
- Native stacktrace [#38](https://github.com/getsentry/sentry-javascript-node-native-stacktrace/pull/38)
18+
- SDKs [#20710](https://github.com/getsentry/sentry-javascript/pull/20710)
19+
20+
## Background: ABI versions
21+
22+
Native addons are compiled against a specific Node.js [ABI version](https://nodejs.org/en/download/releases)
23+
(also called `NODE_MODULE_VERSION`), not the Node major version. Each Node major maps to one ABI:
24+
25+
| Node major | ABI |
26+
| ---------- | --- |
27+
| 18 | 108 |
28+
| 20 | 115 |
29+
| 22 | 127 |
30+
| 24 | 137 |
31+
| 26 | 147 |
32+
33+
You can look up the ABI for a new release at https://nodejs.org/en/download/releases or by running `node -p process.versions.modules`
34+
on the new version.
35+
36+
You'll need this number throughout, binaries are named after it
37+
(e.g. `linux-x64-glibc-147`) for Node 26.
38+
39+
## Step 1: Native CPU profiler binaries
40+
41+
Repo: [sentry-javascript-profiling-node-binaries](https://github.com/getsentry/sentry-javascript-profiling-node-binaries)
42+
43+
Reference PR: [#32](https://github.com/getsentry/sentry-javascript-profiling-node-binaries/pull/32)
44+
45+
1. **Add the build matrix entries.** In `.github/workflows/build.yml`, add a new matrix entry for
46+
the new Node version + ABI for every target platform:
47+
- [ ] `linux-x64-glibc`
48+
- [ ] `linux-x64-musl`,
49+
- [ ] `linux-arm64-glibc`
50+
- [ ] `linux-arm64-musl`
51+
- [ ] `darwin-x64`,
52+
- [ ] `darwin-arm64`,
53+
- [ ] `win32-x64`
54+
55+
The `binary` key follows the `<platform>-<abi>` naming convention (e.g. `linux-x64-glibc-147`).
56+
- Pick the right base container for musl targets — the Alpine tag must include the new Node
57+
version (e.g. `node:26-alpine3.22`).
58+
- **Toolchain caveat:** newer V8 headers may require a newer C++ compiler. Node 26's V8 v14
59+
headers pull in `<source_location>`, which the default compiler in the `ubuntu-20.04` glibc
60+
container is too old to build. A dedicated step upgrades just that target to `gcc-12`/`g++-12`
61+
(via `ppa:ubuntu-toolchain-r/test`). Watch for similar issues on future versions.
62+
63+
2. **Add the runtime ABI resolution.** In `src/index.ts`, add an `if (abi === '<new-abi>')` branch
64+
for each platform that `require`s the new `.node` binary
65+
(e.g. `sentry_cpu_profiler-linux-x64-glibc-147.node`).
66+
3. Release a new version via Craft and note the version number for Step 3.
67+
68+
## Step 2: Native stack trace module
69+
70+
Repo: [sentry-javascript-node-native-stacktrace](https://github.com/getsentry/sentry-javascript-node-native-stacktrace)
71+
72+
Reference PR: [#38](https://github.com/getsentry/sentry-javascript-node-native-stacktrace/pull/38)
73+
74+
This mirrors Step 1 exactly — same matrix additions, same compiler caveat, same `src/index.ts` ABI
75+
branches (here the binaries are named `stack-trace-<platform>-<abi>.node`).
76+
77+
1. Add the new Node version + ABI matrix entries in `.github/workflows/ci.yml` for all platforms.
78+
2. Apply the same compiler upgrade step for the glibc x64 target if the build fails on newer V8
79+
headers.
80+
3. Add the `if (abi === '<new-abi>')` resolution branches in `src/index.ts`.
81+
4. Release a new version via Craft and note the version number for Step 3.
82+
83+
## Step 3: Bump versions in sentry-javascript
84+
85+
Repo: [sentry-javascript](https://github.com/getsentry/sentry-javascript)
86+
87+
Reference: [#20710](https://github.com/getsentry/sentry-javascript/pull/20710)
88+
89+
1. Add the version to the CI test matrix in `.github/workflows/build.yml` to every `node: [18, 20, 22, 24]` entry.
90+
91+
2. Bump the native module dependencies to the versions released in Steps 1 and 2:
92+
- [ ] `@sentry-internal/node-cpu-profiler` in `packages/profiling-node`
93+
- [ ] `@sentry-internal/node-native-stacktrace` in `packages/node-native/package.json`
94+
- [ ] Run `yarn install` to update `yarn.lock`
95+
96+
3. Register the new ABI in the profiling pruner. In
97+
`packages/profiling-node/scripts/prune-profiler-binaries.js`:
98+
- [ ] Add the Node major to ABI mapping to the `NODE_TO_ABI` object (e.g. `26: '147'`).
99+
- [ ] Add the corresponding `else if (NODE.startsWith('26'))` branch.
100+
101+
4. Allow the new major in the profiling integration, in `packages/profiling-node/src/integration.ts`:
102+
- [ ] Add the version number to the `if (![16, 18, 20, 22, 24, 26].includes(NODE_MAJOR))` guard
103+
- [ ] Add the version to the supported-versions list in the `console.warn` message below the guard (the string that reads `...prebuilt support for the following LTS versions of Node.js: 16, 18, 20, 22, 24.`)
104+
105+
5. Handle deprecation warnings. Each new Node version tends to deprecate APIs the SDK (or its dependencies) still use, which can break tests that assert on clean stderr or console output.
106+
107+
6. Fix version-specific test failures, some integrations or test dependencies may not yet work on the new version.

0 commit comments

Comments
 (0)