From 75a76a1a09dfdb0c783f0940d1a1845f776689fa Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Thu, 14 Aug 2025 17:07:40 -0700 Subject: [PATCH 1/4] chore: test against Node.js 24 Now that the mocha + ts-node + Node automatic type-stripping thing is (mostly) sorted, we should be able to test with Node.js 24 now. --- .github/workflows/test-all-versions.yml | 2 +- .github/workflows/unit-test.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-all-versions.yml b/.github/workflows/test-all-versions.yml index 934775c818..04d5e6772f 100644 --- a/.github/workflows/test-all-versions.yml +++ b/.github/workflows/test-all-versions.yml @@ -51,7 +51,7 @@ jobs: strategy: fail-fast: false matrix: - node: ["18", "20", "22"] + node: ["18", "20", "22", "24"] runs-on: ubuntu-latest services: mongo: diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 7c571d2d6d..af296ed5d6 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -48,6 +48,7 @@ jobs: - "20.6.0" - "20" - "22" + - "24" include: - node: 18 code-coverage: true From 5b64b86262a56a8f3d716fbc70005dcf2871dd37 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Thu, 14 Aug 2025 17:34:50 -0700 Subject: [PATCH 2/4] bump instr-knex devDep better-sqlite3 to latest 3.x for Node.js 24 support We shall see if this breaks something with Node.js 18, which seemed to be dropped in the same better-sqlite3 change. --- package-lock.json | 17 +++++++++-------- packages/instrumentation-knex/package.json | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index 93b3e4fa3a..71a9f1cb17 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11791,11 +11791,12 @@ "dev": true }, "node_modules/better-sqlite3": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-11.0.0.tgz", - "integrity": "sha512-1NnNhmT3EZTsKtofJlMox1jkMxdedILury74PwUbQBjWgo4tL4kf7uTAjU55mgQwjdzqakSTjkf+E1imrFwjnA==", + "version": "11.10.0", + "resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-11.10.0.tgz", + "integrity": "sha512-EwhOpyXiOEL/lKzHz9AW1msWFNzGc/z+LzeB3/jnFJpxu+th2yqvzsSWas1v9jgs9+xiXJcD5A8CJxAG2TaghQ==", "dev": true, "hasInstallScript": true, + "license": "MIT", "dependencies": { "bindings": "^1.5.0", "prebuild-install": "^7.1.1" @@ -32564,7 +32565,7 @@ "@opentelemetry/sdk-trace-node": "^2.0.0", "@types/mocha": "10.0.10", "@types/node": "18.18.14", - "better-sqlite3": "11.0.0", + "better-sqlite3": "^11.10.0", "knex": "3.1.0", "nyc": "17.1.0", "rimraf": "5.0.10", @@ -42342,7 +42343,7 @@ "@opentelemetry/semantic-conventions": "^1.33.1", "@types/mocha": "10.0.10", "@types/node": "18.18.14", - "better-sqlite3": "11.0.0", + "better-sqlite3": "^11.10.0", "knex": "3.1.0", "nyc": "17.1.0", "rimraf": "5.0.10", @@ -47881,9 +47882,9 @@ "dev": true }, "better-sqlite3": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-11.0.0.tgz", - "integrity": "sha512-1NnNhmT3EZTsKtofJlMox1jkMxdedILury74PwUbQBjWgo4tL4kf7uTAjU55mgQwjdzqakSTjkf+E1imrFwjnA==", + "version": "11.10.0", + "resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-11.10.0.tgz", + "integrity": "sha512-EwhOpyXiOEL/lKzHz9AW1msWFNzGc/z+LzeB3/jnFJpxu+th2yqvzsSWas1v9jgs9+xiXJcD5A8CJxAG2TaghQ==", "dev": true, "requires": { "bindings": "^1.5.0", diff --git a/packages/instrumentation-knex/package.json b/packages/instrumentation-knex/package.json index 206f6ebc1a..dc5ac86954 100644 --- a/packages/instrumentation-knex/package.json +++ b/packages/instrumentation-knex/package.json @@ -53,7 +53,7 @@ "@opentelemetry/sdk-trace-node": "^2.0.0", "@types/mocha": "10.0.10", "@types/node": "18.18.14", - "better-sqlite3": "11.0.0", + "better-sqlite3": "^11.10.0", "knex": "3.1.0", "nyc": "17.1.0", "rimraf": "5.0.10", From 7fe3396aad8ea35d90c60cde7fc72187f960ebb5 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Fri, 15 Aug 2025 12:52:24 -0700 Subject: [PATCH 3/4] test(instrumentation-restify): skip testing with Node.js 24 and later Restify doesn't support Node.js 24. See https://github.com/restify/node-restify/issues/1876 This adds 'SKIP_TEST_IF_NODE_NEWER_THAN' support to the existing scripts/skip-test-if.js and uses that to handle the skipping. --- packages/instrumentation-restify/.tav.yml | 6 ++- packages/instrumentation-restify/package.json | 2 +- scripts/skip-test-if.js | 50 +++++++++++++------ 3 files changed, 42 insertions(+), 16 deletions(-) diff --git a/packages/instrumentation-restify/.tav.yml b/packages/instrumentation-restify/.tav.yml index 8d354d0d58..371a7cad3f 100644 --- a/packages/instrumentation-restify/.tav.yml +++ b/packages/instrumentation-restify/.tav.yml @@ -2,11 +2,15 @@ restify: - versions: include: '>=10.0.0 <12' mode: latest-minors - node: ">=18" + node: ">=18 <24" commands: npm run test + env: + - SKIP_TEST_IF_DISABLED=true - versions: include: '>=4.1.0 <10' mode: max-7 node: "<18" commands: npm run test + env: + - SKIP_TEST_IF_DISABLED=true diff --git a/packages/instrumentation-restify/package.json b/packages/instrumentation-restify/package.json index 8e4217de21..8306de4012 100644 --- a/packages/instrumentation-restify/package.json +++ b/packages/instrumentation-restify/package.json @@ -18,7 +18,7 @@ "lint:readme": "node ../../scripts/lint-readme.js", "prepublishOnly": "npm run compile", "tdd": "yarn test -- --watch-extensions ts --watch", - "test": "nyc mocha 'test/**/*.ts'", + "test": "SKIP_TEST_IF_NODE_NEWER_THAN=23 nyc mocha --require '../../scripts/skip-test-if.js' 'test/**/*.ts'", "test-all-versions": "tav", "version:update": "node ../../scripts/version-update.js", "watch": "tsc -w" diff --git a/scripts/skip-test-if.js b/scripts/skip-test-if.js index 96be8c483e..8a0772619a 100644 --- a/scripts/skip-test-if.js +++ b/scripts/skip-test-if.js @@ -16,40 +16,62 @@ /** * This script can be used with `mocha --require ...` to support skipping - * tests if the current version of Node.js is too old. For example, say - * a package's unit tests cannot run with Node.js 14, but the CI unit tests - * run all package test with that version. + * tests if the current version of Node.js is too old or too new. For example, + * say a package's unit tests cannot run with Node.js 14, but the CI unit tests + * run all package tests with that version. * * 1. Change this in "package.json": * "test": "nyc mocha ...", - * to this: - * "test": "SKIP_TEST_IF_NODE_OLDER_THAN=18 nyc mocha --require '../../../scripts/skip-test-if.js' ... ", - * where `SKIP_TEST_IF_NODE_OLDER_THAN` indicates the minimum Node.js major - * version. + * to one of these: + * "test": "SKIP_TEST_IF_NODE_OLDER_THAN=18 nyc mocha --require '../../scripts/skip-test-if.js' ...", + * "test": "SKIP_TEST_IF_NODE_NEWER_THAN=22 nyc mocha --require '../../scripts/skip-test-if.js' ...", + * where `SKIP_TEST_IF_NODE_{OLDER|NEWER}_THAN` indicates a Node.js *major* + * version number. * - * 2. ".tav.yml" blocks should set SKIP_TEST_IF_DISABLE=true to + * 2. ".tav.yml" blocks should set SKIP_TEST_IF_DISABLED=true to * disable the skipping. Via this in each test block: * env: - * - SKIP_TEST_IF_DISABLE=true + * - SKIP_TEST_IF_DISABLED=true */ function skipTestIf() { - if (process.env.SKIP_TEST_IF_DISABLE) { + if (process.env.SKIP_TEST_IF_DISABLED) { return; } - const minNodeMajor = process.env.SKIP_TEST_IF_NODE_OLDER_THAN ?? Number(process.env.SKIP_TEST_IF_NODE_OLDER_THAN); - if (!minNodeMajor || isNaN(minNodeMajor)) { - console.warn('skip-test-if warning: set a minimum Node.js major version via SKIP_TEST_IF_NODE_OLDER_THAN='); + let minNodeMajor; + if (process.env.SKIP_TEST_IF_NODE_OLDER_THAN) { + minNodeMajor = Number(process.env.SKIP_TEST_IF_NODE_OLDER_THAN) + if (isNaN(minNodeMajor) || !Number.isInteger(minNodeMajor)) { + console.warn(`skip-test-if warning: ignoring invalid SKIP_TEST_IF_NODE_OLDER_THAN value: "${process.env.SKIP_TEST_IF_NODE_OLDER_THAN}"`); + minNodeMajor = undefined; + } + } + let maxNodeMajor; + if (process.env.SKIP_TEST_IF_NODE_NEWER_THAN) { + maxNodeMajor = Number(process.env.SKIP_TEST_IF_NODE_NEWER_THAN) + if (isNaN(maxNodeMajor) || !Number.isInteger(maxNodeMajor)) { + console.warn(`skip-test-if warning: ignoring invalid SKIP_TEST_IF_NODE_NEWER_THAN value: "${process.env.SKIP_TEST_IF_NODE_NEWER_THAN}"`); + maxNodeMajor = undefined; + } + } + + if (minNodeMajor === undefined && maxNodeMajor === undefined) { + console.warn('skip-test-if warning: skip-test-if.js was used, but no SKIP_TEST_IF_* envvars were set'); return; } const nodeMajor = Number(process.versions.node.split('.')[0]); - if (nodeMajor < minNodeMajor) { + if (minNodeMajor && nodeMajor < minNodeMajor) { process.stderr.write(`skip-test-if: skipping tests on old Node.js (${nodeMajor} < ${minNodeMajor})\n`); // "Skip" tests by exiting the process. Mocha is all in one process. process.exit(0); } + if (maxNodeMajor && nodeMajor > maxNodeMajor) { + process.stderr.write(`skip-test-if: skipping tests on too-new Node.js (${nodeMajor} > ${maxNodeMajor})\n`); + // "Skip" tests by exiting the process. Mocha is all in one process. + process.exit(0); + } } skipTestIf() From bf3208572765818120d5d9681d2580b073ff1ec8 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Fri, 15 Aug 2025 16:28:51 -0700 Subject: [PATCH 4/4] fix test-all-versions for instr-tedious by skipping testing tedious@1 with Node.js 24. tedious@1 cannot run with Node.js 24 --- packages/instrumentation-tedious/.tav.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/instrumentation-tedious/.tav.yml b/packages/instrumentation-tedious/.tav.yml index f61f4456f7..688222b3f4 100644 --- a/packages/instrumentation-tedious/.tav.yml +++ b/packages/instrumentation-tedious/.tav.yml @@ -1,6 +1,13 @@ tedious: - versions: - include: ">=1.11.0 <12" + include: ">=1.11.0 <2" + mode: latest-majors + # tedious@1 uses tls.createSecurePair() which was removed in Node.js 24 + # (https://nodejs.org/api/all.html#DEP0064). + node: "<24" + commands: npm run test + - versions: + include: ">=2 <12" # 4.0.0 is broken: https://github.com/tediousjs/tedious/commit/4eceb48 exclude: "4.0.0" mode: latest-majors