Skip to content

Commit

Permalink
fix: dropped support for node v14 and v16 (#1348)
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
- Dropped support for Node.js versions 14 and 16.
- Reason: These versions have reached their end of life.
- More info: https://github.com/nodejs/Release?tab=readme-ov-file#end-of-life-releases
  • Loading branch information
aryamohanan committed Oct 23, 2024
1 parent 4d28d6b commit aaa9ad4
Show file tree
Hide file tree
Showing 112 changed files with 364 additions and 532 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ body:
attributes:
label: Node.js Version
description: Which version of Node.js are you using?
placeholder: "Node.js 16.7.0"
placeholder: "Node.js 22.9.0"
validations:
required: true
- type: textarea
Expand Down
7 changes: 0 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ Troubleshooting `pg_config: command not found`: The tests in this package depend

Install the [`aws-cli`](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) to publish AWS layers from local.

### Upgrade npm for Node.js v14

If you are using Node.js v14 and would like to take advantage of the "overrides" feature in package.json, you need to upgrade npm manually since Node.js v14 ships with npm v6, and `overrides` were introduced in npm v8.3. Upgrade npm manually to the latest version using the following command:
```
npm install -g npm@latest
```

## Executing Tests Locally

Some of the tests require infrastructure components (databases etc.) to run locally. The easiest way to run all required components locally is to use Docker and on top of this [Docker Compose](https://docs.docker.com/compose/). Start the script `node bin/start-test-containers.js` to run all containers (not recommended).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Bare Node.js 16 image.
# Bare Node.js 22 image.
# Native addons will work since the base image (Debian Buster) has all
# dependencies installed out of the box.

FROM node:16
FROM node:22
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install --only=production
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Bare Alpine image, native addon compilation will fail.
# They will be downloaded on demand at runtime.
# See Dockerfile.node-16.13.0-alpine-3.14-with-native for a Dockerfile that will
# See Dockerfile.node-v22-alpine-with-native for a Dockerfile that will
# build native addons successfully.

FROM node:16.13.0-alpine3.14
FROM node:22-alpine

WORKDIR /usr/src/app
COPY package*.json ./
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# An Alpine image with additional Alpine packages, so native addons can
# be compiled via node-gyp.

FROM node:16.13.0-alpine3.14
FROM node:22-alpine

WORKDIR /usr/src/app
COPY package*.json ./

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Bare Node.js 16 image, using yarn.
# Bare Node.js 22 image, using yarn.
# Native addons will work since the base image (Debian Buster) has all
# dependencies installed out of the box.

FROM node:16.13.0
FROM node:22
WORKDIR /usr/src/app
COPY package*.json ./
RUN yarn
Expand Down
2 changes: 1 addition & 1 deletion dockerfile-examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Dockerizing your Node.js application is a thing. Since the Instana Node.js colle

This is probably relevant for you
- dockerize your Node.js application
- and are using a minimal Docker image (such as the popular Alpine variants of the popular official [Node.js Docker images](https://hub.docker.com/_/node/),
- and are using a minimal Docker image such as the popular Alpine variants of the popular official [Node.js Docker images](https://hub.docker.com/_/node/),
- or another base image that does not have all required packages installed,
- see `node-gyp` errors during your Docker build (in particular the `npm install`/`yarn install` step).

Expand Down
2 changes: 1 addition & 1 deletion dockerfile-examples/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3'

services:
node:
image: node-16.13.0-instana
image: node-22-instana
networks:
node-agent-network:
aliases:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ set -e


source ./build-and-run
buildAndRun node-16.13.0-alpine-3.14-with-native
buildAndRun node-v22-alpine-with-native

Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ set -e


source ./build-and-run
buildAndRun node-16.13.0-yarn
buildAndRun node-v22-alpine

Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ set -e


source ./build-and-run
buildAndRun node-16.13.0-alpine-3.14
buildAndRun node-v22-yarn

Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ set -e


source ./build-and-run
buildAndRun node-16.13.0
buildAndRun node-v22

5 changes: 1 addition & 4 deletions native-dep-packs/rebuild-precompiled-addons.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ cd `dirname $BASH_SOURCE`
# Maintenance Note:
# This should be kept in sync with packages/autoprofile/precompile/build-all-addons.js-> ABI_VERSIONS.
declare -A ABI_VERSIONS=( \
["83"]="14.21.3" \
["93"]="16.20.2" \
["108"]="18.18.2" \
["115"]="20.3.0" \
["120"]="21.2.0" \
Expand Down Expand Up @@ -73,5 +71,4 @@ if [[ ! -z "$BUILD_FOR_MACOS" ]]; then
echo Native addons for MacOS can only be built on MacOS.
exit 1
fi
fi

fi
19 changes: 11 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"packages/*"
],
"license": "MIT",
"engines": {
"node": ">=18.0.0"
},
"contributors": [
{
"name": "Katharina Irrgang",
Expand Down
8 changes: 4 additions & 4 deletions packages/autoprofile/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ Supported arch:
### Rebuilding existing Node.js versions

```sh
node scripts/prebuilds.js --os=darwin --node=14.0.0 [build v14 only for darwin]
node scripts/prebuilds.js --os=linux --node=18.0.0 [build v14 only for linux]
node scripts/prebuilds.js --os=darwin --node=20.0.0 [build v20 only for darwin]
node scripts/prebuilds.js --os=linux --node=18.0.0 [build v18 only for linux]
node scripts/prebuilds.js --os=linux --arch=linux-arm64 --node=18.0.0 [build v18 only for linux arm64]
node scripts/prebuilds.js --node=14.0.0 [build specific node version]
node scripts/prebuilds.js --node=14.0.0,21.0.0 [build specific node versions]
node scripts/prebuilds.js --node22.0.0 [build specific node version]
node scripts/prebuilds.js --node=22.0.0,21.0.0 [build specific node versions]
```

### Adding support for a new Node.js version
Expand Down
2 changes: 1 addition & 1 deletion packages/autoprofile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"semver": "^7.5.4"
},
"engines": {
"node": ">=14.0.0"
"node": ">=18.0.0"
},
"main": "index.js",
"files": [
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions packages/autoprofile/scripts/prebuilds.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
* This is just a wrapper around the CLI commands `prebuildify` and `prebuildify-cross`.
*
* Instead of using this wrapper, you can manually run the commands:
* npx prebuildify -t node@14.0.0 -t [email protected] -t node@18.0.0 -t [email protected] -t [email protected] --strip --arch arm64
* npx prebuildify-cross --modules ../../node_modules -i linux-arm64 -t node@14.0.0 --strip
* npx prebuildify -t [email protected] -t [email protected] -t [email protected] --strip --arch arm64
* npx prebuildify-cross --modules ../../node_modules -i linux-arm64 -t node@18.0.0 --strip
*/

const yargs = require('yargs/yargs');
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-fargate/images/test-images/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
# - local -> use a local Docker base image
# - aws -> use an image from the AWS ECR registry with test base images
# $2: Node.js version. One of:
# - 18
# - 20
# - 18
# $3: Linux distribution. One of:
# - standard -> (uses node:$version, that is, Debian)
# - alpine -> (uses node:$version-alpine, that is, Alpine, and installs build dependencies)
Expand Down
27 changes: 20 additions & 7 deletions packages/aws-fargate/images/test-images/utils
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,18 @@ function normalizeArgs {
fi

local nodeJsVersion=$2
ROOT_DIR=$(git rev-parse --show-toplevel)
local MINIMUM_NODEJS_VERSION=$(getMinimumNodeVersionFromPackageJson)

if [[ -z "${nodeJsVersion-}" ]]; then
ROOT_DIR=$(git rev-parse --show-toplevel)
NVMRC_PATH="$ROOT_DIR/.nvmrc"
NODEJS_VERSION=$(cat "$NVMRC_PATH")
elif [[ $nodeJsVersion -lt 14 ]]; then
echo "Unsupported Node version: $nodeJsVersion"
exit 1
NVMRC_PATH="$ROOT_DIR/.nvmrc"
NODEJS_VERSION=$(<"$NVMRC_PATH")
else
NODEJS_VERSION=$nodeJsVersion
if ! printf "%s\n%s" "$MINIMUM_NODEJS_VERSION" "$nodeJsVersion" | sort -C -V; then
echo "Unsupported Node.js version: $nodeJsVersion. Minimum required: $MINIMUM_NODEJS_VERSION."
exit 1
fi
NODEJS_VERSION=$nodeJsVersion
fi


Expand Down Expand Up @@ -99,3 +102,13 @@ function setContainerName {

container_name=$prefix-$nodeJsVersion$distribution-$instanaLayerMode-$docker_tag
}
function getMinimumNodeVersionFromPackageJson {
local package_json_path="$ROOT_DIR/package.json"
if [[ -f "$package_json_path" ]]; then
MINIMUM_NODEJS_VERSION=$(grep '"node":' "$package_json_path" | awk -F '"' '{print $4}' | sed 's/^>=//; s/\..*//')
echo "$MINIMUM_NODEJS_VERSION"
else
echo "Could not find package.json in $ROOT_DIR"
exit 1
fi
}
2 changes: 1 addition & 1 deletion packages/aws-fargate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@
"@instana/serverless": "3.21.0"
},
"engines": {
"node": ">=14.0.0"
"node": ">=18.0.0"
}
}
4 changes: 2 additions & 2 deletions packages/aws-fargate/test/esm/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const account = '555123456789';
const instrumentedContainerName = 'nodejs-fargate-test-container';
const taskArn = `arn:aws:ecs:${region}:${account}:task/55566677-c1e5-5780-9806-aabbccddeeff`;
const instrumentedContainerId = `${taskArn}::${instrumentedContainerName}`;
const esmSupportedVersion = require('@instana/core').tracing.esmSupportedVersion;
const supportedVersion = require('@instana/core').tracing.supportedVersion;
const containerAppPath = path.join(__dirname, './app.mjs');
const instanaAgentKey = 'aws-fargate-dummy-key';
const requestHeaders = {
Expand Down Expand Up @@ -52,7 +52,7 @@ function prelude(opts = {}) {
}

// Run the tests only for supported node versions
if (esmSupportedVersion(process.versions.node)) {
if (supportedVersion(process.versions.node)) {
describe('AWS fargate esm test', function () {
this.timeout(config.getTestTimeout());
this.slow(config.getTestTimeout() / 2);
Expand Down
9 changes: 3 additions & 6 deletions packages/aws-lambda-auto-wrap/esm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,14 @@
'use strict';

const instana = require('@instana/aws-lambda');
const supportedVersion = require('@instana/core').tracing.supportedVersion;
const localUtils = require('./utils');

const majorNodeVersion = Number(process.versions.node.split('.')[0]);

// CASE: ES support was added in Node v14, throw error if the handler is used in < 14
// NOTE: The esm handler can be used for Lambdas with commonjs or es module.
// See https://github.com/nodejs/node/pull/35249
// NOTE: v3 dropped support for < Node v14
if (majorNodeVersion < 14) {
if (!supportedVersion(process.versions.node)) {
throw new localUtils.errors.lambda.ImportModuleError(
`Your Lambda function is using ${majorNodeVersion}. This version is not supported.` +
`Your Lambda function is using ${process.versions.node}. This version is not supported.` +
'Please use a layer version which is compatible with your Node.js version.' +
'See https://www.ibm.com/docs/en/instana-observability/current?topic=lambda-aws-native-tracing-nodejs'
);
Expand Down
7 changes: 0 additions & 7 deletions packages/aws-lambda-auto-wrap/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const path = require('path');
const SPLIT_AT_DOT_REGEX = /^([^.]*)\.(.*)$/;
const TWO_DOTS = '..';
const DEFAULT_HANDLER = 'index.handler';
const RUNTIME_PATH = '/var/runtime';

class HandlerNotFound extends Error {}
class MalformedHandlerName extends Error {}
Expand All @@ -37,12 +36,6 @@ function getLambdaRuntimeErrors() {
if (lambdaRuntimeErrors) {
return lambdaRuntimeErrors;
}

// NOTE: Lambda v16 removed the ability to require `Error.js`
if (Number(process.versions.node.split('.')[0]) < 16) {
return require(`${RUNTIME_PATH}/Errors.js`);
}

return lambdaRuntimeErrorsFallback;
}

Expand Down
5 changes: 3 additions & 2 deletions packages/aws-lambda-auto-wrap/test/esm_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ const sinon = require('sinon');
const semver = require('semver');
const expect = require('chai').expect;
const instana = require('@instana/aws-lambda');
const supportedVersion = require('@instana/core').tracing.supportedVersion;

describe('esm wrapper', function () {
if (semver.lt(process.versions.node, '14.0.0')) {
if (!supportedVersion(process.versions.node)) {
const majorNodeVersion = semver.major(process.versions.node);

it(`should throw error for Node v${majorNodeVersion}`, () => {
try {
require('../esm/index');
} catch (e) {
expect(e.message).to.eql(
`ES Module support was added in Node v14. Your Lambda function is using ${majorNodeVersion}.` +
`Your Lambda function is using ${majorNodeVersion}.` +
"Please use the 'instana-aws-lambda-auto-wrap.handler' as runtime handler."
);
}
Expand Down
Loading

0 comments on commit aaa9ad4

Please sign in to comment.