Skip to content

Commit afe008a

Browse files
trentmPeterEinberger
authored andcommitted
fix: restore ESM testing with Node.js >=v18.19.0 and v20 and v21; clarify ESM Node.js version support (elastic#3857)
With the recent update to [email protected] our ESM support is working with Node.js v18.19.0, and with v20 and v21 (`^18.1.0 || >=20.2.0`)
1 parent 1a96920 commit afe008a

File tree

5 files changed

+39
-13
lines changed

5 files changed

+39
-13
lines changed

.ci/tav.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
2-
"// versions": "Skip >=18.19.0 until IITM double-import issue is resolved.",
3-
"versions": [ "21", "20", "18.18.2", "16", "14" ],
2+
"versions": [ "21", "20", "18", "16", "14" ],
43
"// modules": [
54
"List of instrumented modules with the minimum Node major version supported.",
65
"minMajorVersion for each module should be kept in sync with .tav.yml"

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ jobs:
130130
- '21.0'
131131
- '20'
132132
- '20.0'
133-
- '18.18.2' # Skip >=18.19.0 until IITM double-import issue is resolved.
133+
- '18'
134134
- '18.0'
135135
- '16'
136136
- '16.0'

CHANGELOG.asciidoc

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,35 @@ Notes:
3434
See the <<upgrade-to-v4>> guide.
3535
3636
37+
==== Unreleased
38+
39+
[float]
40+
===== Breaking changes
41+
42+
[float]
43+
===== Features
44+
45+
[float]
46+
===== Bug fixes
47+
48+
* Add support for <<esm,instrumentation of ES module-using (ESM) code>> with
49+
Node.js versions matching `^18.19.0 || >=20.2.0`. Before this version of
50+
the APM agent, ESM instrumentation was only supported for some *earlier*
51+
Node.js versions. Changes in Node.js's ESM loader in v18.19.0 and v20 broke
52+
earlier ESM support. ({issues}3784[#3784], {pull}3844[#3844])
53+
54+
[float]
55+
===== Chores
56+
57+
3758
[[release-notes-4.4.0]]
3859
==== 4.4.0 - 2024/01/12
3960
61+
*Known issue*: Using the APM agent's <<esm>> with Node.js *v18.19.0* is not
62+
supported in this version. Upgrade to APM agent version v4.5.0 or later, or use
63+
Node.js v18.18.1 or earlier.
64+
See https://github.com/elastic/apm-agent-nodejs/issues/3784 for details.
65+
4066
[float]
4167
===== Features
4268
@@ -60,10 +86,10 @@ See the <<upgrade-to-v4>> guide.
6086
[[release-notes-4.3.0]]
6187
==== 4.3.0 - 2023/12/05
6288
63-
*Known issue*: Using the APM agent's <<esm>> with Node v18.19.0 is currently
64-
not supported. Earlier versions of Node.js v18 and Node.js v20 and later
65-
*are* supported. See <https://github.com/elastic/apm-agent-nodejs/issues/3784>
66-
for details.
89+
*Known issue*: Using the APM agent's <<esm>> with Node.js *v18.19.0* is not
90+
supported in this version. Upgrade to APM agent version v4.5.0 or later, or use
91+
Node.js v18.18.1 or earlier.
92+
See https://github.com/elastic/apm-agent-nodejs/issues/3784 for details.
6793
6894
[float]
6995
===== Features

docs/esm.asciidoc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,9 @@ As well, the APM agent must also be separately *started* -- for example via `--r
7070

7171
Automatic instrumentation of ES modules is based on the experimental Node.js Loaders API. ESM support in the Elastic APM Node.js agent will remain *experimental* while the Loaders API is experimental.
7272

73-
ESM auto-instrumentation is only supported for Node.js versions that match *`^12.20.0 || ^14.13.1 || ^16.0.0 || ^18.1.0 <20`*.
73+
ESM auto-instrumentation is only supported for Node.js versions that match *`^12.20.0 || ^14.13.1 || ^16.0.0 || ^18.1.0 || >=20.2.0`*.
7474
The behavior when using `node --experimental-loader=elastic-apm-node/loader.mjs` with earlier Node.js versions is undefined and unsupported.
7575

76-
Notably, ESM auto-instrumentation is *not* supported with Node.js v20 because of changes in the Loaders API. Using the loader with Node.js v20 can result in crashes in `import ...` statements that attempt named imports from some CommonJS modules. The error message will be of the form `SyntaxError: The requested module '<module name>' does not provide an export named '<export name>'`. (You can track https://github.com/DataDog/import-in-the-middle/issues/29[this issue] for progress.)
77-
7876

7977
[float]
8078
[[esm-compat-modules]]

test/testconsts.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ const os = require('os');
1515
// fixes in the .1 minor release
1616
// - v18.1.0 fixes an issue in v18.0.0
1717
// https://github.com/nodejs/node/pull/42881
18-
// - Current node v20 does not work with IITM
18+
// - `^18.19.0 || >=20` support was added by IITM@1.7.3
1919
// https://github.com/DataDog/import-in-the-middle/pull/27
20-
const NODE_VER_RANGE_IITM = '^12.20.0 || ^14.13.1 || ^16.0.0 || ^18.1.0 <20';
21-
const NODE_VER_RANGE_IITM_GE14 = '^14.13.1 || ^16.0.0 || ^18.1.0 <20'; // NODE_VER_RANGE_IITM minus node v12
20+
// - v20.2.0 fixes an issue in v20
21+
// I think it is https://github.com/nodejs/node/issues/47929
22+
const NODE_VER_RANGE_IITM =
23+
'^12.20.0 || ^14.13.1 || ^16.0.0 || ^18.1.0 || >=20.2.0';
24+
const NODE_VER_RANGE_IITM_GE14 = '^14.13.1 || ^16.0.0 || ^18.1.0 || >=20.2.0'; // NODE_VER_RANGE_IITM minus node v12
2225

2326
// This can be passed as tape test options for tests that are timing sensitive,
2427
// to *skip* those tests on Windows CI.

0 commit comments

Comments
 (0)