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

ES module replacement changed in Node 18.6 #495

Closed
tari opened this issue Jul 18, 2022 · 5 comments
Closed

ES module replacement changed in Node 18.6 #495

tari opened this issue Jul 18, 2022 · 5 comments

Comments

@tari
Copy link

tari commented Jul 18, 2022

Description

Node 18.6 breaks ES module replacement.

Issue

Starting from Node 18.6.0, the ES module replacement API provided by node is changed in an incompatible way that causes runtime failure. Representative output from running my package's tests:

$ mocha --loader=testdouble my/test
(node:43) ExperimentalWarning: Custom ESM Loaders is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:43) DeprecationWarning: Obsolete loader hook(s) supplied and will be ignored: getFormat, getSource
  connection handling
    1) "before each" hook for "connects"
    2) "after each" hook for "connects"
  0 passing (680ms)
  2 failing
  1) "before each" hook for "connects":
     Error [ERR_LOADER_CHAIN_INCOMPLETE]: "testdouble 'load'" did not call the next hook in its chain and did not explicitly signal a short circuit. If this is intentional, include `shortCircuit: true` in the hook's return.
      at new NodeError (node:internal/errors:387:5)
      at ESMLoader.load (node:internal/modules/esm/loader:624:13)
      at async ESMLoader.moduleProvider (node:internal/modules/esm/loader:472:11)
      at async link (node:internal/modules/esm/module_job:67:21)
  2) "after each" hook for "connects":
     TypeError: Failed to execute 'removeChild' on 'Node': parameter 1 is not of type 'Node'.
      at Object.convert (node_modules/jsdom/lib/jsdom/living/generated/Node.js:749:11)
      at HTMLBodyElement.removeChild (node_modules/jsdom/lib/jsdom/living/generated/Node.js:323:29)
      at Context.<anonymous> (file:///builds/cemetech/7/sax/frontend/test/ui.test.mjs:26:17)
      at process.processImmediate (node:internal/timers:471:21)

Environment

node:current docker image, currently corresponding to 18.6.0 (node@sha256:c9504e6bdd0498b99acbf392b94e4d0d56b2c6a37e52b5766cfb909894d9f389).

@searls
Copy link
Member

searls commented Jul 18, 2022

Can you share what version of quibble you're using? @giltayar just made a change in quibble@0.6.12 that likely fixes this

@tari
Copy link
Author

tari commented Jul 18, 2022

Looks like I'm on 0.6.8 right now. I'll check that updating fixes it.

@giltayar
Copy link
Collaborator

The update fixes exactly that. :-)

@tari
Copy link
Author

tari commented Jul 19, 2022

Verified that updating quibble to 0.6.12 in my environment fixes the issue; thanks!

@tari tari closed this as completed Jul 19, 2022
@FossPrime
Copy link

Found this issue on google, so hope this helps anyone who also does...

Had the same issue with Mocha 10 combined with ts-node 10.7.0. Updated ts-node to 10.9.1 and that fixed the issue.

Of note... I'm on Node LTS 16.17.0, which means the change has been backported. I'm not sure what the best solution for loading typescript into mocha is in 2022, but if using experimental features is still necessary, I'd rather just with naked Node.js or Vitest instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants