Skip to content

Declare Node.js >=22.12.0 engine and test Node 22 in CI - #11

Open
nucliweb wants to merge 2 commits into
ChromeDevTools:mainfrom
nucliweb:add-node-engines-field
Open

nucliweb wants to merge 2 commits into
ChromeDevTools:mainfrom
nucliweb:add-node-engines-field

Conversation

@nucliweb

@nucliweb nucliweb commented Nov 9, 2026 •

Copy link
Copy Markdown

Part of #9.

The CLI needs Node 22, but package.json does not say so. On Node 20.18.2:

  • trace-engine-cli scan 'fixtures/*.json' --name RunTask fails with Error: fs.globSync is not a function.
  • npm test fails with Could not find '.../test/**/*.test.ts', because node --test does not expand globs in Node 20.

yargs@18 declares ^20.19.0 || ^22.12.0 || >=23. fs.globSync is experimental before 22.17.0, so on 22.12–22.16 every scan with a glob prints an ExperimentalWarning to stderr. The effective minimum is 22.17.0.

Changes

  • Add "engines": { "node": ">=22.17.0" } to package.json and the lockfile.
  • Run CI on a Node 22.17.0, 22 and 24 matrix with fail-fast: false, so CI runs the declared minimum.
  • Add a glob scan call to the CI smoke test, so CI runs the code path that needs Node 22.
  • Document the requirement in the README.

Verification

  • npm run check, npm run build and npm test (135 tests) pass on Node 22.17.0, 22.18.0 and 25.3.0.
  • Packed the package with npm pack and installed the tarball in a clean project:
    • Node 20.18.2: npm prints EBADENGINE ... required: { node: '>=22.12.0' } (before the floor moved to 22.17.0).
    • Node 22.18.0 and 24.15.0: installs cleanly and the glob scan works.
  • Ran the glob scan on 22.12.0 and 22.16.0: both print the globSync ExperimentalWarning. 22.17.0 does not.

Note: with the matrix, the CI checks are named check-test-build (22.17.0), check-test-build (22) and check-test-build (24). If main requires a status check named check-test-build, that setting needs an update.

The CLI already needs Node 22: `scan` uses `fs.globSync` and `npm test` relies on glob patterns in `node --test`, and neither works in Node 20. `yargs@18` also declares `^22.12.0` for the 22 line. Without an `engines` field, npm installs the package on Node 20 without a warning and `scan` fails at runtime with `fs.globSync is not a function`.

- Add `"engines": { "node": ">=22.12.0" }` to package.json.
- Run CI on Node 22 and 24.
- Add a glob `scan` smoke test to CI so the Node 22 API runs in CI.
- Document the requirement in the README.

Refs ChromeDevTools#9

@mangeshraut712 mangeshraut712 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch on the yargs floor pushing the 22.x minimum to 22.12, and adding the glob scan call to the smoke test means CI now exercises the Node 22-only code path. One suggestion on what the matrix actually tests.

Comment thread .github/workflows/ci.yml Outdated
contents: read
strategy:
matrix:
node-version: ['22', '24']

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'22' resolves to the newest 22.x on the runner (22.18+ today), so CI never runs the version the engines field promises, 22.12.0. If something later uses an API or behaviour that only arrived in a later 22 minor, CI stays green while >=22.12.0 users break. Adding the floor explicitly, e.g. node-version: ['22.12.0', '22', '24'], would keep the declared minimum honest.

Related, and worth checking on that floor version: as far as I recall, fs.globSync was still marked experimental for part of the 22.x line (I believe it was stabilised around 22.17 / 24.0). If so, scan on 22.12–22.16 would print an ExperimentalWarning to stderr on every run. That's harmless for exit codes, but noisy for a CLI whose output people pipe. A 22.12.0 matrix leg would show it right away. Optional: fail-fast: false on the matrix so one leg failing doesn't cancel the other.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, the warning is real. On 22.12.0 and 22.16.0, scan with a glob prints ExperimentalWarning: globSync is an experimental feature and might change at any time to stderr. On 22.17.0 it does not. I raised the floor to >=22.17.0 in engines and the README, added 22.17.0 as a matrix leg and set fail-fast: false in f13a460. Tests, check and build pass on 22.17.0.

fs.globSync is experimental before Node 22.17.0, so scan with a glob prints an ExperimentalWarning to stderr on 22.12–22.16. Raise the engines floor to 22.17.0, add 22.17.0 as a CI matrix leg so CI runs the declared minimum, and set fail-fast to false.
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.

2 participants