Skip to content

shims broken in v11 when using Datadog loader hook #584

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

Open
yo1dog opened this issue Apr 24, 2025 · 0 comments
Open

shims broken in v11 when using Datadog loader hook #584

yo1dog opened this issue Apr 24, 2025 · 0 comments

Comments

@yo1dog
Copy link

yo1dog commented Apr 24, 2025

versions:

  • node: v22.14.0
  • @mux/mux-node: v11.0.0, v11.0.1, and v11.0.2
  • dd-trace: 5.45.0
  • import-in-the-middle: 1.13.1

Example code:

// test.mjs
import Mux from '@mux/mux-node';

This works with all versions of mux:

node test.mjs

This works with mux v10, but fails with mux v11:

node --import dd-trace/register.js test.mjs
file:///home/mike/work/rocky-api/node_modules/@mux/mux-node/_shims/registry.mjs:17
        throw new Error(`you must \`import '@mux/mux-node/shims/${shims.kind}'\` before importing anything else from @mux/mux-node`);
              ^

Error: you must `import '@mux/mux-node/shims/node'` before importing anything else from @mux/mux-node
    at Module.setShims (file:///home/mike/work/rocky-api/node_modules/@mux/mux-node/_shims/registry.mjs:17:15)
    at init (file:///home/mike/work/rocky-api/node_modules/@mux/mux-node/_shims/index.mjs:7:26)
    at file:///home/mike/work/rocky-api/node_modules/@mux/mux-node/core.mjs:17:1
    at ModuleJob.run (node:internal/modules/esm/module_job:271:25)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:578:26)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5)

Node.js v22.14.0

Adding import '@mux/mux-node/shims/node'; before the other import in test.mjs results in:

Error: can't `import '@mux/mux-node/shims/node'` after `import '@mux/mux-node/shims/node'`
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

1 participant