Skip to content

Commit 8d80c1b

Browse files
committed
fix: enforced Node.js 18.19 as the minimum supported version
1 parent 0b41e6e commit 8d80c1b

File tree

17 files changed

+55
-16
lines changed

17 files changed

+55
-16
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
],
2020
"license": "MIT",
2121
"engines": {
22-
"node": ">=18.0.0"
22+
"node": ">=18.19.0"
2323
},
2424
"contributors": [
2525
{

packages/autoprofile/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"semver": "^7.7.3"
5757
},
5858
"engines": {
59-
"node": ">=18.0.0"
59+
"node": ">=18.19.0"
6060
},
6161
"main": "index.js",
6262
"files": [

packages/aws-fargate/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,6 @@
7171
"@instana/serverless": "4.29.0"
7272
},
7373
"engines": {
74-
"node": ">=18.0.0"
74+
"node": ">=18.19.0"
7575
}
7676
}

packages/aws-lambda/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"tracing"
4949
],
5050
"engines": {
51-
"node": ">=18.0.0"
51+
"node": ">=18.19.0"
5252
},
5353
"contributors": [
5454
{

packages/azure-container-services/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"url": "https://github.com/instana/nodejs/issues"
6363
},
6464
"engines": {
65-
"node": ">=18.0.0"
65+
"node": ">=18.19.0"
6666
},
6767
"license": "MIT",
6868
"dependencies": {

packages/collector/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"url": "git+https://github.com/instana/nodejs.git"
3232
},
3333
"engines": {
34-
"node": ">=18.0.0"
34+
"node": ">=18.19.0"
3535
},
3636
"scripts": {
3737
"audit": "npm audit --omit=dev",

packages/core/src/tracing/instrumentation/protocols/nativeFetch.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ let isActive = false;
3333
exports.shouldAddHeadersToOptionsUnconditionally = function () {
3434
return (
3535
semver.eq(process.version, '21.0.0') ||
36-
(semver.gte(process.version, '20.8.1') && semver.lt(process.version, '20.10.0')) ||
37-
(semver.gte(process.version, '18.18.2') && semver.lt(process.version, '18.19.0'))
36+
(semver.gte(process.version, '20.8.1') && semver.lt(process.version, '20.10.0'))
3837
);
3938
};
4039

packages/core/src/util/nodeJsVersionCheck.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/**
88
* This is the minimum required Node.js version for all @instana packages.
99
*/
10-
exports.minimumNodeJsVersion = 18;
10+
exports.minimumNodeJsVersion = '18.19.0';
1111

1212
/**
1313
* Checks if the value of process.version denotes a Node.js version that is not supported, that is, older than the given
@@ -18,10 +18,21 @@ exports.minimumNodeJsVersion = 18;
1818
exports.isNodeJsTooOld = function isNodeJsTooOld() {
1919
const currentVersion = process.version;
2020
if (typeof currentVersion === 'string') {
21-
const majorVersionStr = process.version.split('.')[0];
21+
const parts = currentVersion.split('.');
22+
const majorVersionStr = parts[0];
2223
if (majorVersionStr.length > 1 && majorVersionStr.charAt(0) === 'v') {
23-
const majorVersion = parseInt(majorVersionStr.substring(1), 10);
24-
return !isNaN(majorVersion) && majorVersion < exports.minimumNodeJsVersion;
24+
const major = parseInt(majorVersionStr.slice(1), 10);
25+
const minor = parseInt(parts[1], 10);
26+
const patch = parseInt(parts[2], 10);
27+
28+
if (isNaN(major) || isNaN(minor) || isNaN(patch)) return false;
29+
30+
const [minMajor, minMinor, minPatch] = exports.minimumNodeJsVersion.split('.').map(Number);
31+
return (
32+
major < minMajor ||
33+
(major === minMajor && minor < minMinor) ||
34+
(major === minMajor && minor === minMinor && patch < minPatch)
35+
);
2536
}
2637
}
2738
return false;

packages/core/test/tracing/supportedVersion_test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ const supportedTracingVersion = require('../../src/tracing/supportedVersion');
1111

1212
describe('supported versions for Node.js auto tracing', () => {
1313
it('must support various Node.js versions', () => {
14-
expect(supportedTracingVersion('18.1.1')).to.equal(true);
14+
expect(supportedTracingVersion('18.19.0')).to.equal(true);
1515
expect(supportedTracingVersion('20.0.0')).to.equal(true);
1616
expect(supportedTracingVersion('21.2.0')).to.equal(true);
1717
expect(supportedTracingVersion('22.0.0')).to.equal(true);
1818
expect(supportedTracingVersion('23.0.0')).to.equal(true);
1919
expect(supportedTracingVersion('24.0.0')).to.equal(true);
20+
expect(supportedTracingVersion('25.0.0')).to.equal(true);
2021
});
2122

2223
it('must report various Node.js versions as not supported', () => {
@@ -45,5 +46,6 @@ describe('supported versions for Node.js auto tracing', () => {
4546
expect(supportedTracingVersion('12.0.0')).to.equal(false);
4647
expect(supportedTracingVersion('14.0.0')).to.equal(false);
4748
expect(supportedTracingVersion('16.1.0')).to.equal(false);
49+
expect(supportedTracingVersion('18.18.0')).to.equal(false);
4850
});
4951
});

packages/core/test/util/nodeJsTooOld_test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,21 @@ describe('util.nodeJsTooOld', () => {
7777
expect(isNodeJsTooOld()).to.be.true;
7878
});
7979

80+
it('should reject Node.js 18.18.0', () => {
81+
setProcessVersion('v18.18.0');
82+
expect(isNodeJsTooOld()).to.be.true;
83+
});
84+
85+
it('should reject Node.js 18.18.9', () => {
86+
setProcessVersion('v18.18.0');
87+
expect(isNodeJsTooOld()).to.be.true;
88+
});
89+
90+
it('should accept Node.js 18.19.0', () => {
91+
setProcessVersion('v18.19.0');
92+
expect(isNodeJsTooOld()).to.be.false;
93+
});
94+
8095
it('should accept if process.version is not set', () => {
8196
setProcessVersion(undefined);
8297
expect(isNodeJsTooOld()).to.be.false;

0 commit comments

Comments
 (0)