Skip to content

Tests broken with externalized undici #58865

Description

@richardlau

Version

24.3.0, 22.17.0

Platform

Linux

Subsystem

No response

What steps will reproduce the bug?

To reproduce:

  1. Clone https://github.com/nodejs/undici.
  2. Build undici with EXTERNAL_PATH environment variable set. e.g.
EXTERNAL_PATH=/home/rlau/sandbox/github/undici node build/wasm.js --docker
  1. Delete deps/undici from Node.js (downstream builders such as Fedora do this to ensure the externalized version of undici is being used instead of the in-tree copy in Node.js).
  2. Configure Node.js to use the externalized undici from step 2 (note that loader.js is generated during step 2.).
./configure --shared-builtin-undici/undici-path /home/rlau/sandbox/github/undici/loader.js
  1. Build Node.js and run tests.

How often does it reproduce? Is there a required condition?

Every time

What is the expected behavior? Why is that the expected behavior?

Tests pass on all supported release lines of Node.js.

What do you see instead?

For Node.js 22, this test fails:
https://github.com/nodejs/undici/actions/runs/15926591410/job/44925161073

=== release test-inspector-network-fetch ===
Path: parallel/test-inspector-network-fetch
--- stderr ---
Debugger listening on ws://127.0.0.1:43805/7add9ccb-dd3b-471d-bf52-d3b5e0431cc1
For help, see: https://nodejs.org/en/docs/inspector
node:internal/modules/cjs/loader:1404
  throw err;
  ^

Error: Cannot find module '../../deps/undici/src/index.js'
Require stack:
- /home/runner/work/undici/undici/node-v22.17.0/test/parallel/test-inspector-network-fetch.js
    at Function._resolveFilename (node:internal/modules/cjs/loader:1401:15)
    at defaultResolveImpl (node:internal/modules/cjs/loader:1057:19)
    at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1062:22)
    at Function._load (node:internal/modules/cjs/loader:1211:37)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
    at Module.require (node:internal/modules/cjs/loader:1487:12)
    at require (node:internal/modules/helpers:135:16)
    at Object.<anonymous> (/home/runner/work/undici/undici/node-v22.17.0/test/parallel/test-inspector-network-fetch.js:15:16)
    at Module._compile (node:internal/modules/cjs/loader:1730:14) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/runner/work/undici/undici/node-v22.17.0/test/parallel/test-inspector-network-fetch.js'
  ]
}

Node.js v22.17.0
Command: out/Release/node --inspect=0 --experimental-network-inspection --test-reporter=./test/common/test-error-reporter.js --test-reporter-destination=stdout /home/runner/work/undici/undici/node-v22.17.0/test/parallel/test-inspector-network-fetch.js

For Node.js 24,
https://github.com/nodejs/undici/actions/runs/15926591410/job/44925161078

=== release test-http-proxy-fetch ===
Path: parallel/test-http-proxy-fetch
--- stderr ---
node:internal/process/promises:394
    triggerUncaughtException(err, true /* fromPromise */);
    ^

AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
+ actual - expected

  {
+   code: 1,
-   code: 0,
    signal: null,
+   stderr: 'node:internal/assert:11\n' +
+     '    throw new ERR_INTERNAL_ASSERTION(message);\n' +
+     '    ^\n' +
+     '\n' +
+     'Error [ERR_INTERNAL_ASSERTION]: This is caused by either a bug in Node.js or incorrect usage of Node.js internals.\n' +
+     'Please open an issue with this stack trace at https://github.com/nodejs/node/issues\n' +
+     '\n' +
+     '    at assert (node:internal/assert:11:11)\n' +
+     '    at setupUserModules (node:internal/process/pre_execution:187:3)\n' +
+     '    at prepareExecution (node:internal/process/pre_execution:159:5)\n' +
+     '    at prepareMainThreadExecution (node:internal/process/pre_execution:46:10)\n' +
+     '    at node:internal/main/run_main_module:15:19 {\n' +
+     "  code: 'ERR_INTERNAL_ASSERTION'\n" +
+     '}\n' +
+     '\n' +
+     'Node.js v24.3.0',
+   stdout: ''
-   stderr: '',
-   stdout: 'Hello world'
  }

    at exports.checkProxiedRequest (/home/runner/work/undici/undici/node-v24.3.0/test/common/proxy-server.js:89:10)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async /home/runner/work/undici/undici/node-v24.3.0/test/parallel/test-http-proxy-fetch.js:39:3 {
  generatedMessage: true,
  code: 'ERR_ASSERTION',
  actual: {
    stderr: 'node:internal/assert:11\n' +
      '    throw new ERR_INTERNAL_ASSERTION(message);\n' +
      '    ^\n' +
      '\n' +
      'Error [ERR_INTERNAL_ASSERTION]: This is caused by either a bug in Node.js or incorrect usage of Node.js internals.\n' +
      'Please open an issue with this stack trace at https://github.com/nodejs/node/issues\n' +
      '\n' +
      '    at assert (node:internal/assert:11:11)\n' +
      '    at setupUserModules (node:internal/process/pre_execution:187:3)\n' +
      '    at prepareExecution (node:internal/process/pre_execution:159:5)\n' +
      '    at prepareMainThreadExecution (node:internal/process/pre_execution:46:10)\n' +
      '    at node:internal/main/run_main_module:15:19 {\n' +
      "  code: 'ERR_INTERNAL_ASSERTION'\n" +
      '}\n' +
      '\n' +
      'Node.js v24.3.0',
    stdout: '',
    code: 1,
    signal: null
  },
  expected: { stderr: '', code: 0, signal: null, stdout: 'Hello world' },
  operator: 'deepStrictEqual'
}

Node.js v24.3.0
Command: out/Release/node --test-reporter=./test/common/test-error-reporter.js --test-reporter-destination=stdout /home/runner/work/undici/undici/node-v24.3.0/test/parallel/test-http-proxy-fetch.js
=== release test-https-proxy-fetch ===
Path: parallel/test-https-proxy-fetch
--- stderr ---
node:internal/process/promises:394
    triggerUncaughtException(err, true /* fromPromise */);
    ^

AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
+ actual - expected

  {
+   code: 1,
-   code: 0,
    signal: null,
+   stderr: 'node:internal/assert:11\n' +
+     '    throw new ERR_INTERNAL_ASSERTION(message);\n' +
+     '    ^\n' +
+     '\n' +
+     'Error [ERR_INTERNAL_ASSERTION]: This is caused by either a bug in Node.js or incorrect usage of Node.js internals.\n' +
+     'Please open an issue with this stack trace at https://github.com/nodejs/node/issues\n' +
+     '\n' +
+     '    at assert (node:internal/assert:11:11)\n' +
+     '    at setupUserModules (node:internal/process/pre_execution:187:3)\n' +
+     '    at prepareExecution (node:internal/process/pre_execution:159:5)\n' +
+     '    at prepareMainThreadExecution (node:internal/process/pre_execution:46:10)\n' +
+     '    at node:internal/main/run_main_module:15:19 {\n' +
+     "  code: 'ERR_INTERNAL_ASSERTION'\n" +
+     '}\n' +
+     '\n' +
+     'Node.js v24.3.0',
+   stdout: ''
-   stderr: '',
-   stdout: 'Hello world'
  }

    at exports.checkProxiedRequest (/home/runner/work/undici/undici/node-v24.3.0/test/common/proxy-server.js:89:10)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async /home/runner/work/undici/undici/node-v24.3.0/test/parallel/test-https-proxy-fetch.js:43:3 {
  generatedMessage: true,
  code: 'ERR_ASSERTION',
  actual: {
    stderr: 'node:internal/assert:11\n' +
      '    throw new ERR_INTERNAL_ASSERTION(message);\n' +
      '    ^\n' +
      '\n' +
      'Error [ERR_INTERNAL_ASSERTION]: This is caused by either a bug in Node.js or incorrect usage of Node.js internals.\n' +
      'Please open an issue with this stack trace at https://github.com/nodejs/node/issues\n' +
      '\n' +
      '    at assert (node:internal/assert:11:11)\n' +
      '    at setupUserModules (node:internal/process/pre_execution:187:3)\n' +
      '    at prepareExecution (node:internal/process/pre_execution:159:5)\n' +
      '    at prepareMainThreadExecution (node:internal/process/pre_execution:46:10)\n' +
      '    at node:internal/main/run_main_module:15:19 {\n' +
      "  code: 'ERR_INTERNAL_ASSERTION'\n" +
      '}\n' +
      '\n' +
      'Node.js v24.3.0',
    stdout: '',
    code: 1,
    signal: null
  },
  expected: { stderr: '', code: 0, signal: null, stdout: 'Hello world' },
  operator: 'deepStrictEqual'
}

Node.js v24.3.0
Command: out/Release/node --test-reporter=./test/common/test-error-reporter.js --test-reporter-destination=stdout /home/runner/work/undici/undici/node-v24.3.0/test/parallel/test-https-proxy-fetch.js
=== release test-inspector-network-fetch ===
Path: parallel/test-inspector-network-fetch
--- stderr ---
Debugger listening on ws://127.0.0.1:42081/5b84e2a3-7770-4357-8970-7a0a5f457a0f
For help, see: https://nodejs.org/en/docs/inspector
node:internal/modules/cjs/loader:1372
  throw err;
  ^

Error: Cannot find module '../../deps/undici/src/index.js'
Require stack:
- /home/runner/work/undici/undici/node-v24.3.0/test/parallel/test-inspector-network-fetch.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1369:15)
    at defaultResolveImpl (node:internal/modules/cjs/loader:1025:19)
    at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1030:22)
    at Module._load (node:internal/modules/cjs/loader:1179:37)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
    at Module.require (node:internal/modules/cjs/loader:1449:12)
    at require (node:internal/modules/helpers:135:16)
    at Object.<anonymous> (/home/runner/work/undici/undici/node-v24.3.0/test/parallel/test-inspector-network-fetch.js:15:16)
    at Module._compile (node:internal/modules/cjs/loader:16[92](https://github.com/nodejs/undici/actions/runs/15926591410/job/44925161078#step:13:93):14) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/runner/work/undici/undici/node-v24.3.0/test/parallel/test-inspector-network-fetch.js'
  ]
}

Node.js v24.3.0
Command: out/Release/node --inspect=0 --experimental-network-inspection --test-reporter=./test/common/test-error-reporter.js --test-reporter-destination=stdout /home/runner/work/undici/undici/node-v24.3.0/test/parallel/test-inspector-network-fetch.js

i.e.

  • parallel/test-http-proxy-fetch.js (Node.js 24)
  • parallel/test-https-proxy-fetch.js (Node.js 24)
  • parallel/test-inspector-network-fetch.js (Node.js 22, 24)

Additional information

When building Node.js with an externalized copy of undici, some tests fail. This was noticed on https://github.com/nodejs/undici/: nodejs/undici#4276

e.g. https://github.com/nodejs/undici/actions/runs/15926591410

Activity

  1. richardlau commented on Jun 27, 2025

    @richardlau
    MemberAuthor
    • parallel/test-inspector-network-fetch.js (Node.js 22, 24)

    This was caused by #56488, specifically

    const undici = require('../../deps/undici/src/index.js');
    doesn't work if deps/undici doesn't exist, which downstream builders (such as Fedora) would typically do to ensure the externalized version of undici is being used instead of the in-tree copy in Node.js. I've opened #58866 for review.

    • parallel/test-http-proxy-fetch.js (Node.js 24)
    • parallel/test-https-proxy-fetch.js (Node.js 24)

    These tests were introduced by the #57165 feature (which is labelled baking-for-lts and hence not on Node.js 22... yet). We're tripping this assertion

    assert(!hasStartedUserCJSExecution());
    and I think I'll need help figuring out what is going on here (maybe @joyeecheung ?).

  2. added
    testIssues and PRs related to Node.js core tests and test infrastructure.
    on Jun 29, 2025
  3. joyeecheung commented on Jul 2, 2025

    @joyeecheung
    Member

    I will need to take a deeper look but from a glance of the error message, it looks like the externalisation is loading the original Undici code from disk using the user land module loader before the user land module loader is properly initialized. Moving the undici initialization until after the user land module loader initialization may fix it. Or another alternative is for the externalisation to load the modules from disk using the builtin module loader tweaked to read from disk instead of memory, and don't use the user land loader for this. That may make it more future proof for any other dependencies that need to be externalised in the future.

  4. joyeecheung commented on Jul 3, 2025

    @joyeecheung
    Member

    Tried reproducing it, FWIW step 2 does not actually generate loader.js because the --docker branch would just process.exit(0) after it's done generating wasm and never gets to the branch below to generate loader.js

  5. richardlau commented on Jul 3, 2025

    @richardlau
    MemberAuthor

    Tried reproducing it, FWIW step 2 does not actually generate loader.js because the --docker branch would just process.exit(0) after it's done generating wasm and never gets to the branch below to generate loader.js

    Ah sorry, I missed the process.exit call -- I was trying to simplify the reproduce. The non-Docker build is in https://github.com/nodejs/undici/blob/main/.github/workflows/nodejs-shared.yml (Linux distros prefer to build things from source).
    Thanks for #58938.

  6. joyeecheung commented on Jul 16, 2025

    @joyeecheung
    Member

    Should this be closed now?

  7. richardlau commented on Jul 16, 2025

    @richardlau
    MemberAuthor

    Should this be closed now?

    I'm using this as a reminder to track the fixes through to Node.js 24 and 22 so I can re-enabled the disabled CI in https://github.com/nodejs/undici.

  8. richardlau commented on Jul 16, 2025

    @richardlau
    MemberAuthor

    but if you like I could open an Undici issue to re-enable the disabled CI and track there and close this one?

  9. joyeecheung commented on Jul 17, 2025

    @joyeecheung
    Member

    I am okay with keeping this open, asking just in case we accidentally leave another issue open forever ;)

  10. linked a pull request that will close this issueci: reenable shared builtin CI tests #4426on Aug 18, 2025
  11. kapouer commented on Sep 4, 2025

    @kapouer
    Contributor

    3. Delete deps/undici from Node.js (downstream builders such as Fedora do this to ensure the externalized version of undici is being used instead of the in-tree copy in Node.js).

    It would have been great if original poster used @nodejs/distros instead of "Fedora" ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    testIssues and PRs related to Node.js core tests and test infrastructure.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions