Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🛠 Repo: Test failures in test-node:integration with Node.js 22 #5213

Closed
5 tasks done
JoshuaKGoldberg opened this issue Sep 12, 2024 · 4 comments
Closed
5 tasks done
Labels
area: repository tooling concerning ease of contribution status: accepting prs Mocha can use your help with this one! type: chore generally involving deps, tooling, configuration, etc.

Comments

@JoshuaKGoldberg
Copy link
Member

Tooling Suggestion Checklist

Overview

Examples from https://github.com/mochajs/mocha/actions/runs/10822537285/job/30049014667:


  1) esm
       should throw an ERR_MODULE_NOT_FOUND and not ERR_REQUIRE_ESM if file imports a non-existing module with a loader:
     
...


  2) root hooks
       when mocha run in serial mode
         support ESM via .js extension w/o type=module
           should fail due to ambiguous file type:
Full, long output here... 323 passing (2m) 1 pending 2 failing
  1. esm
    should throw an ERR_MODULE_NOT_FOUND and not ERR_REQUIRE_ESM if file imports a non-existing module with a loader:

expected '(node:2221) ExperimentalWarning: --experimental-loader may be removed in the future; instead use register():\n--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("./test/integration/fixtures/esm/loader-with-module-not-found/loader-that-recognizes-ts.mjs", pathToFileURL("./"));'\n at createModuleLoader (node:internal/modules/esm/loader:710:17)\n at Object.getOrInitializeCascadedLoader (node:internal/modules/esm/loader:754:22)\n at asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:106:65)\n at runEntryPointWithESMLoader (node:internal/modules/run_main:139:19)\n at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:173:5)\n at node:internal/main/run_main_module:30:49\n\n Exception during run: Error [ERR_INTERNAL_ASSERTION]: This is caused by either a bug in Node.js or incorrect usage of Node.js internals.\nPlease open an issue with this stack trace at https://github.com/nodejs/node/issues\n\n at assert (node:internal/assert:14:11)\n at ModuleLoader.getModuleJobForRequire (node:internal/modules/esm/loader:329:5)\n at new ModuleJobSync (node:internal/modules/esm/module_job:313:34)\n at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:314:11)\n at loadESMFromCJS (node:internal/modules/cjs/loader:1381:24)\n at Module._compile (node:internal/modules/cjs/loader:1503:5)\n at Module.replacementCompile (/home/runner/work/mocha/mocha/node_modules/append-transform/index.js:60:13)\n at module.exports (/home/runner/work/mocha/mocha/node_modules/default-require-extensions/js.js:7:9)\n at Object. (/home/runner/work/mocha/mocha/node_modules/append-transform/index.js:64:4)\n at Module.load (node:internal/modules/cjs/loader:1317:32)\n at Module._load (node:internal/modules/cjs/loader:1127:12)\n at TracingChannel.traceSync (node:diagnostics_channel:315:14)\n at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)\n at Module.require (node:internal/modules/cjs/loader:1339:12)\n at require (node:internal/modules/helpers:135:16)\n at exports.requireOrImport (/home/runner/work/mocha/mocha/lib/nodejs/esm-utils.js:10:8)\n at async exports.loadFilesAsync (/home/runner/work/mocha/mocha/lib/nodejs/esm-utils.js:21:688)\n at async singleRun (/home/runner/work/mocha/mocha/lib/cli/run-helpers.js:55:26)\n at async exports.handler (/home/runner/work/mocha/mocha/lib/cli/run.js:19:452) {\n code: 'ERR_INTERNAL_ASSERTION'\n}\n'
to contain 'ERR_MODULE_NOT_FOUND'

(node:2221) ExperimentalWarning: --experimental-loader may be removed in the future; instead use register():
--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("./test/integration/fixtures/esm/loader-with-module-not-found/loader-that-recognizes-ts.mjs", pathToFileURL("./"));'
at createModuleLoader (node:internal/modules/esm/loader:710:17)
at Object.getOrInitializeCascadedLoader (node:internal/modules/esm/loader:754:22)
at asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:106:65)
at runEntryPointWithESMLoader (node:internal/modules/run_main:139:19)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:173:5)
at node:internal/main/run_main_module:30:49

Exception during run: Error [ERR_INTERNAL_ASSERTION]: This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
^^^^
Please open an issue with this stack trace at https://github.com/nodejs/node/issues

at assert (node:internal/assert:14:11)
at ModuleLoader.getModuleJobForRequire (node:internal/modules/esm/loader:329:5)
at new ModuleJobSync (node:internal/modules/esm/module_job:313:34)
at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:314:11)
at loadESMFromCJS (node:internal/modules/cjs/loader:1381:24)
at Module._compile (node:internal/modules/cjs/loader:1503:5)
at Module.replacementCompile (/home/runner/work/mocha/mocha/node_modules/append-transform/index.js:60:13)
at module.exports (/home/runner/work/mocha/mocha/node_modules/default-require-extensions/js.js:7:9)
at Object.<anonymous> (/home/runner/work/mocha/mocha/node_modules/append-transform/index.js:64:4)
at Module.load (node:internal/modules/cjs/loader:1317:32)
at Module._load (node:internal/modules/cjs/loader:1127:12)
at TracingChannel.traceSync (node:diagnostics_channel:315:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
at Module.require (node:internal/modules/cjs/loader:1339:12)
at require (node:internal/modules/helpers:135:16)
at exports.requireOrImport (/home/runner/work/mocha/mocha/lib/nodejs/esm-utils.js:10:8)
at async exports.loadFilesAsync (/home/runner/work/mocha/mocha/lib/nodejs/esm-utils.js:21:688)
at async singleRun (/home/runner/work/mocha/mocha/lib/cli/run-helpers.js:55:26)
at async exports.handler (/home/runner/work/mocha/mocha/lib/cli/run.js:19:452) {

code: 'ERR_INTERNAL_ASSERTION'
^^^^
}

UnexpectedError:
expected '(node:2221) ExperimentalWarning: --experimental-loader may be removed in the future; instead use register():\n--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("./test/integration/fixtures/esm/loader-with-module-not-found/loader-that-recognizes-ts.mjs", pathToFileURL("./"));'\n at createModuleLoader (node:internal/modules/esm/loader:710:17)\n at Object.getOrInitializeCascadedLoader (node:internal/modules/esm/loader:754:22)\n at asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:106:65)\n at runEntryPointWithESMLoader (node:internal/modules/run_main:139:19)\n at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:173:5)\n at node:internal/main/run_main_module:30:49\n\n Exception during run: Error [ERR_INTERNAL_ASSERTION]: This is caused by either a bug in Node.js or incorrect usage of Node.js internals.\nPlease open an issue with this stack trace at https://github.com/nodejs/node/issues\n\n at assert (node:internal/assert:14:11)\n at ModuleLoader.getModuleJobForRequire (node:internal/modules/esm/loader:329:5)\n at new ModuleJobSync (node:internal/modules/esm/module_job:313:34)\n at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:314:11)\n at loadESMFromCJS (node:internal/modules/cjs/loader:1381:24)\n at Module._compile (node:internal/modules/cjs/loader:1503:5)\n at Module.replacementCompile (/home/runner/work/mocha/mocha/node_modules/append-transform/index.js:60:13)\n at module.exports (/home/runner/work/mocha/mocha/node_modules/default-require-extensions/js.js:7:9)\n at Object. (/home/runner/work/mocha/mocha/node_modules/append-transform/index.js:64:4)\n at Module.load (node:internal/modules/cjs/loader:1317:32)\n at Module._load (node:internal/modules/cjs/loader:1127:12)\n at TracingChannel.traceSync (node:diagnostics_channel:315:14)\n at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)\n at Module.require (node:internal/modules/cjs/loader:1339:12)\n at require (node:internal/modules/helpers:135:16)\n at exports.requireOrImport (/home/runner/work/mocha/mocha/lib/nodejs/esm-utils.js:10:8)\n at async exports.loadFilesAsync (/home/runner/work/mocha/mocha/lib/nodejs/esm-utils.js:21:688)\n at async singleRun (/home/runner/work/mocha/mocha/lib/cli/run-helpers.js:55:26)\n at async exports.handler (/home/runner/work/mocha/mocha/lib/cli/run.js:19:452) {\n code: 'ERR_INTERNAL_ASSERTION'\n}\n'
to contain 'ERR_MODULE_NOT_FOUND'

(node:2221) ExperimentalWarning: --experimental-loader may be removed in the future; instead use register():
--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("./test/integration/fixtures/esm/loader-with-module-not-found/loader-that-recognizes-ts.mjs", pathToFileURL("./"));'
at createModuleLoader (node:internal/modules/esm/loader:710:17)
at Object.getOrInitializeCascadedLoader (node:internal/modules/esm/loader:754:22)
at asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:106:65)
at runEntryPointWithESMLoader (node:internal/modules/run_main:139:19)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:173:5)
at node:internal/main/run_main_module:30:49

Exception during run: Error [ERR_INTERNAL_ASSERTION]: This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
^^^^
Please open an issue with this stack trace at https://github.com/nodejs/node/issues

  at assert (node:internal/assert:14:11)
  at ModuleLoader.getModuleJobForRequire (node:internal/modules/esm/loader:329:5)
  at new ModuleJobSync (node:internal/modules/esm/module_job:313:34)
  at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:314:11)
  at loadESMFromCJS (node:internal/modules/cjs/loader:1381:24)
  at Module._compile (node:internal/modules/cjs/loader:1503:5)
  at Module.replacementCompile (node_modules/append-transform/index.js:60:13)
  at module.exports (node_modules/default-require-extensions/js.js:7:9)
  at Object.<anonymous> (node_modules/append-transform/index.js:64:4)
  at Module.load (node:internal/modules/cjs/loader:1317:32)
  at Module._load (node:internal/modules/cjs/loader:1127:12)
  at TracingChannel.traceSync (node:diagnostics_channel:315:14)
  at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
  at Module.require (node:internal/modules/cjs/loader:1339:12)
  at require (node:internal/modules/helpers:135:16)
  at exports.requireOrImport (lib/nodejs/esm-utils.js:10:8)
  at async exports.loadFilesAsync (lib/nodejs/esm-utils.js:21:688)
  at async singleRun (lib/cli/run-helpers.js:55:26)
  at async exports.handler (/home/runner/work/mocha/mocha/lib/cli/run.js:19:452) {
code: 'ERR_INTERNAL_ASSERTION'
       ^^^^

}

  at Context.<anonymous> (test/integration/esm.spec.js:100:5)
  at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
  set UNEXPECTED_FULL_TRACE=true to see the full stack trace
  1. root hooks
    when mocha run in serial mode
    support ESM via .js extension w/o type=module
    should fail due to ambiguous file type:

expected Promise when fulfilled to contain output /SyntaxError: Unexpected token/
expected
{
output: '\n✖ \x1b[31mERROR:\x1b[39m Error [ERR_REQUIRE_CYCLE_MODULE]: Cannot require() ES Module /home/runner/work/mocha/mocha/test/integration/fixtures/plugins/root-hooks/root-hook-defs-esm-broken.fixture.js in a cycle.\n at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:303:15)\n at loadESMFromCJS (node:internal/modules/cjs/loader:1381:24)\n at Module._compile (node:internal/modules/cjs/loader:1503:5)\n at Module.replacementCompile (/home/runner/work/mocha/mocha/node_modules/append-transform/index.js:60:13)\n at Module._extensions..js (node:internal/modules/cjs/loader:1691:10)\n at Object. (/home/runner/work/mocha/mocha/node_modules/append-transform/index.js:64:4)\n at Module.load (node:internal/modules/cjs/loader:1317:32)\n at Module._load (node:internal/modules/cjs/loader:1127:12)\n at TracingChannel.traceSync (node:diagnostics_channel:315:14)\n at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)\n at cjsLoader (node:internal/modules/esm/translators:329:5)\n at ModuleWrap. (node:internal/modules/esm/translators:260:7)\n at ModuleJob.run (node:internal/modules/esm/module_job:262:25)\n at async onImport.tracePromise.proto (node:internal/modules/esm/loader:482:26)\n at async formattedImport (/home/runner/work/mocha/mocha/lib/nodejs/esm-utils.js:2:567)\n at async exports.requireOrImport (/home/runner/work/mocha/mocha/lib/nodejs/esm-utils.js:7:1135)\n at async exports.handleRequires (/home/runner/work/mocha/mocha/lib/cli/run-helpers.js:38:372)\n at async /home/runner/work/mocha/mocha/lib/cli/run.js:18:40 {\n code: 'ERR_REQUIRE_CYCLE_MODULE'\n}\n',
code: 1,
args: [
'/home/runner/work/mocha/mocha/bin/mocha.js',
'--require=/home/runner/work/mocha/mocha/test/integration/fixtures/plugins/root-hooks/root-hook-defs-esm-broken.fixture.js',
'--no-color',
'--no-bail',
'--no-parallel'
],
command: '/home/runner/work/mocha/mocha/bin/mocha.js --require=/home/runner/work/mocha/mocha/test/integration/fixtures/plugins/root-hooks/root-hook-defs-esm-broken.fixture.js --no-color --no-bail --no-parallel'
}
to contain output /SyntaxError: Unexpected token/

expected Promise when fulfilled to contain output /SyntaxError: Unexpected token/
expected
{
output: '\n✖ \x1b[31mERROR:\x1b[39m Error [ERR_REQUIRE_CYCLE_MODULE]: Cannot require() ES Module /home/runner/work/mocha/mocha/test/integration/fixtures/plugins/root-hooks/root-hook-defs-esm-broken.fixture.js in a cycle.\n at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:303:15)\n at loadESMFromCJS (node:internal/modules/cjs/loader:1381:24)\n at Module._compile (node:internal/modules/cjs/loader:1503:5)\n at Module.replacementCompile (/home/runner/work/mocha/mocha/node_modules/append-transform/index.js:60:13)\n at Module._extensions..js (node:internal/modules/cjs/loader:1691:10)\n at Object. (/home/runner/work/mocha/mocha/node_modules/append-transform/index.js:64:4)\n at Module.load (node:internal/modules/cjs/loader:1317:32)\n at Module._load (node:internal/modules/cjs/loader:1127:12)\n at TracingChannel.traceSync (node:diagnostics_channel:315:14)\n at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)\n at cjsLoader (node:internal/modules/esm/translators:329:5)\n at ModuleWrap. (node:internal/modules/esm/translators:260:7)\n at ModuleJob.run (node:internal/modules/esm/module_job:262:25)\n at async onImport.tracePromise.proto (node:internal/modules/esm/loader:482:26)\n at async formattedImport (/home/runner/work/mocha/mocha/lib/nodejs/esm-utils.js:2:567)\n at async exports.requireOrImport (/home/runner/work/mocha/mocha/lib/nodejs/esm-utils.js:7:1135)\n at async exports.handleRequires (/home/runner/work/mocha/mocha/lib/cli/run-helpers.js:38:372)\n at async /home/runner/work/mocha/mocha/lib/cli/run.js:18:40 {\n code: 'ERR_REQUIRE_CYCLE_MODULE'\n}\n',
code: 1,
args: [
'--require=/home/runner/work/mocha/mocha/test/integration/fixtures/plugins/root-hooks/root-hook-defs-esm-broken.fixture.js',
'--no-color',
'--no-bail',
'--no-parallel'
],
}
to contain output /SyntaxError: Unexpected token/
at Array.forEach ()
From previous event:
at Context. (test/integration/plugins/root-hooks.spec.js:140:16)
at callFn (lib/runnable.js:110:584)
at Runnable.run (lib/runnable.js:110:57)
at Runner.runTest (lib/runner.js:182:1028)
at /home/runner/work/mocha/mocha/lib/runner.js:210:639
at next (lib/runner.js:159:412)
at /home/runner/work/mocha/mocha/lib/runner.js:159:789
at next (lib/runner.js:147:565)
at Immediate. (lib/runner.js:151:1226)
at process.processImmediate (node:internal/timers:491:21)
set UNEXPECTED_FULL_TRACE=true to see the full stack trace

Additional Info

No response

@JoshuaKGoldberg JoshuaKGoldberg added area: repository tooling concerning ease of contribution status: in triage a maintainer should (re-)triage (review) this issue labels Sep 12, 2024
@JoshuaKGoldberg JoshuaKGoldberg added status: accepting prs Mocha can use your help with this one! type: chore generally involving deps, tooling, configuration, etc. and removed status: in triage a maintainer should (re-)triage (review) this issue labels Oct 8, 2024
@mark-wiemer
Copy link
Contributor

Ref #5219, happy to advise anyone who wants to look into this :)

@TG199
Copy link
Contributor

TG199 commented Nov 10, 2024

Hi @mark-wiemer, I'm new to contributing to mocha and I'd like to start with this. I'd appreciate any form of guide on the issue, thanks!

@mark-wiemer
Copy link
Contributor

mark-wiemer commented Nov 10, 2024

Hmm, @JoshuaKGoldberg is this still open? I can't see any recent failures for this and it looks like #5219 was merged after this bug was opened! Ref this recent run on main in which all checks passed: https://github.com/mochajs/mocha/actions/runs/11596781766/job/32288924202

Some very recent runs on main have some failures, but not with Node 22

@JoshuaKGoldberg
Copy link
Member Author

😄 great, looks like it resolved itself. Love to see it!

If they come up again, we can reopen this issue and note them as being nondeterministic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: repository tooling concerning ease of contribution status: accepting prs Mocha can use your help with this one! type: chore generally involving deps, tooling, configuration, etc.
Projects
None yet
Development

No branches or pull requests

3 participants