|
| 1 | +### Node-test workflow failure on release branch – root cause analysis |
| 2 | + |
| 3 | +#### What I ran (mirroring .github/workflows/test_node.yml) |
| 4 | +- Install (skip binary download): |
| 5 | +```bash |
| 6 | +SENTRYCLI_SKIP_DOWNLOAD=1 npm ci |
| 7 | +``` |
| 8 | +- Type check: |
| 9 | +```bash |
| 10 | +npm run check:types |
| 11 | +``` |
| 12 | +- Tests (matrix job runs this across Node 10.x, 12.x, 14.x, 16.x, 18.x, 20.x, 22.x, 24.x): |
| 13 | +```bash |
| 14 | +npm test |
| 15 | +``` |
| 16 | + |
| 17 | +Environment used locally: Node v22.16.0, npm 10.9.2 on Linux. |
| 18 | + |
| 19 | +#### Observations |
| 20 | +- Type checks and tests pass locally on Node v22. |
| 21 | +- Jest prints a warning before running tests: |
| 22 | +``` |
| 23 | +Multiple configurations found: |
| 24 | + * /workspace/jest.config.js |
| 25 | + * `jest` key in /workspace/package.json |
| 26 | +``` |
| 27 | + Tests still pass, but this can cause non-zero exits with some setups. |
| 28 | +- TypeScript in this branch is 5.8.3 (see package-lock) which declares engines { node: ">=14.17" }. |
| 29 | + |
| 30 | +#### Why the workflow fails only on the release branch |
| 31 | +- The reusable workflow `.github/workflows/test_node.yml` has two jobs: |
| 32 | + - `type_check` uses: |
| 33 | + ```yaml |
| 34 | + - name: Use Node.js |
| 35 | + uses: actions/setup-node@… |
| 36 | + with: |
| 37 | + node-version-file: package.json |
| 38 | + ``` |
| 39 | + This causes the action to read the Node version specifier from `package.json`. |
| 40 | + - In this branch, `package.json` has: |
| 41 | + ```json |
| 42 | + "engines": { "node": ">= 10" } |
| 43 | + ``` |
| 44 | + With `node-version-file`, setup-node interprets this spec and resolves a Node version which can be ≤12 on some runners. If the resolved version is <14.17 (for example 10.x/12.x), running the type check (`tsc`) fails because TypeScript 5.8.3 requires Node ≥14.17. |
| 45 | +- The matrix job `test_node` is unaffected by TypeScript’s engine requirement (it doesn’t run `tsc`) and generally passes across versions because dev tooling is compatible with older Node. The failure is therefore isolated to the `type_check` job selection of Node. |
| 46 | +- On master, the workflow likely uses a pinned Node version for `type_check` or `engines.node` was raised, so `type_check` runs with Node ≥14.17 and passes. |
| 47 | + |
| 48 | +#### Concrete evidence in repo |
| 49 | +- `package.json`: |
| 50 | +```json |
| 51 | +"devDependencies": { "typescript": "~5.8.3", … }, |
| 52 | +"engines": { "node": ">= 10" }, |
| 53 | +"volta": { "node": "24.8.0" } |
| 54 | +``` |
| 55 | +- `typescript@5.8.3` requires Node ≥14.17. Running `tsc` under Node 10/12 will fail. |
| 56 | +- `test_node.yml` uses `node-version-file: package.json` for `type_check`, which can yield an older Node than TypeScript supports. |
| 57 | + |
| 58 | +#### Root cause |
| 59 | +`type_check` is executed with a Node version that is too old for the TypeScript version in this branch due to using `node-version-file: package.json` where `engines.node` is set to ">= 10". This mismatch causes the type-check step to fail on the release branch, while master uses a newer Node (e.g., pinned) and passes. |
| 60 | + |
| 61 | +#### Recommended fixes |
| 62 | +Pick one of the following (can be combined for robustness): |
| 63 | + |
| 64 | +1) Pin a modern Node version for the `type_check` job |
| 65 | +```yaml |
| 66 | +# .github/workflows/test_node.yml |
| 67 | +- name: Use Node.js |
| 68 | + uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # 5.0.0 |
| 69 | + with: |
| 70 | + node-version: '20.x' # or '22.x' / '24.x' |
| 71 | + # remove node-version-file here |
| 72 | +``` |
| 73 | + |
| 74 | +2) Raise the minimum engine in `package.json` to match dev tooling |
| 75 | +```json |
| 76 | +"engines": { "node": ">= 14.17" } |
| 77 | +``` |
| 78 | +This helps prevent local/CI ambiguity and aligns with TypeScript’s requirement. |
| 79 | + |
| 80 | +3) Optional: Remove the duplicate Jest configuration source |
| 81 | +- Keep `jest.config.js` and delete the `jest` key in `package.json`, or change the npm script to pass `--config jest.config.js`. |
| 82 | +This removes the “Multiple configurations found” warning that could become fatal under stricter CI settings. |
| 83 | + |
| 84 | +#### Notes on release-branch specifics |
| 85 | +- The workflow already works around missing platform-specific optional binaries on release branches by using npm (not yarn) and setting `SENTRYCLI_SKIP_DOWNLOAD=1`. This is not the cause of the current failure. |
| 86 | + |
| 87 | +#### Quick validation |
| 88 | +- Locally, forcing an older Node (≤12) for the type-check step would reproduce the failure because `tsc` (5.8.3) cannot run on Node <14.17. Upgrading the `type_check` Node to ≥14.17 (ideally 20+) will resolve the release-branch failure. |
| 89 | + |
0 commit comments