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

Node v14.17.6 causing the node:crypto module not found issue #2357

Closed
architgarg95 opened this issue Jul 30, 2024 · 13 comments
Closed

Node v14.17.6 causing the node:crypto module not found issue #2357

architgarg95 opened this issue Jul 30, 2024 · 13 comments
Assignees
Labels
bug Something isn't working

Comments

@architgarg95
Copy link

What version of OpenTelemetry are you using?

0.52.0

What version of Node are you using?

v14.17.6

What did you do?

implemented simple telemetry

What did you expect to see?

telemetry starting correctly and exporting data correctly

What did you see instead?

application fails to run becuase of node:crypto module not found

Additional context

This issue occurs only with the node v14.17.6 or prior version, somehow getting the error node:crypto module not found which in the call stack shows is required by gcp-detector, this gcp-detector internally uses the gaxios which is further dependent on 'node:crypto' module

Error stack below:

Error: Cannot find module 'node:crypto'
[0] Require stack:
[0] - .../src/main/node/node_modules/gaxios/node_modules/uuid/dist/rng.js
[0] - .../src/main/node/node_modules/gaxios/node_modules/uuid/dist/v1.js
[0] - .../src/main/node/node_modules/gaxios/node_modules/uuid/dist/index.js
[0] - .../src/main/node/node_modules/gaxios/build/src/gaxios.js
[0] - .../src/main/node/node_modules/gaxios/build/src/index.js
[0] - .../src/main/node/node_modules/gcp-metadata/build/src/index.js
[0] - .../src/main/node/node_modules/@opentelemetry/resource-detector-gcp/build/src/detectors/GcpDetector.js
[0] - .../src/main/node/node_modules/@opentelemetry/resource-detector-gcp/build/src/detectors/index.js
[0] - .../src/main/node/node_modules/@opentelemetry/resource-detector-gcp/build/src/index.js
[0] - .../src/main/node/node_modules/@opentelemetry/auto-instrumentations-node/build/src/utils.js
[0] - .../src/main/node/node_modules/@opentelemetry/auto-instrumentations-node/build/src/index.js

@architgarg95 architgarg95 added the bug Something isn't working label Jul 30, 2024
@architgarg95
Copy link
Author

Does anyone know about this??

@dyladan
Copy link
Member

dyladan commented Jul 31, 2024

The quickest workaround here assuming you aren't on GCP is to install the instrumentations and detectors you need manually without using the auto-instrumentations-node package. That package adds a lot of things and dependencies and it looks like we may not have control over this.

@dyladan
Copy link
Member

dyladan commented Jul 31, 2024

One other thing you can try is to update to at least 14.18.x which adds support for require('node:*') style imports.

@trentm
Copy link
Contributor

trentm commented Jul 31, 2024

I'll try to track down the dep update that resulted in this. I'm guessing it is a transitive dep, so pinning is hard.

@trentm
Copy link
Contributor

trentm commented Jul 31, 2024

I wonder if this could have been from googleapis/gaxios#638
There was a short while when gaxios@6 (the current version used by @opentelemetry/resource-detector-gcp had a dependency on uuid@10, which broke support for earlier Node.js v14. Then gaxios reverted back to uuid@9.

@architgarg95 Could you please show the output of npm ls gaxios and npm ls uuid on your tree that is hitting this issue?

@trentm
Copy link
Contributor

trentm commented Jul 31, 2024

Actually, it looks like there has not been a new gaxios@6 release since it moved back to using uuid@9.
gaxios@6.7.0 is the problematic verison.
So a workaround, until there is a new gaxios release, would be to pin to release gaxios@6.6.0, if possible.

@trentm
Copy link
Contributor

trentm commented Jul 31, 2024

I knew this was familiar, I reported this earlier: googleapis/gaxios#637
The result of that was the googleapis/gaxios#638 fix. We are now just waiting for a new release of gaxios.

@architgarg95
Copy link
Author

I wonder if this could have been from googleapis/gaxios#638
There was a short while when gaxios@6 (the current version used by @opentelemetry/resource-detector-gcp had a dependency on uuid@10, which broke support for earlier Node.js v14. Then gaxios reverted back to uuid@9.

@architgarg95 Could you please show the output of npm ls gaxios and npm ls uuid on your tree that is hitting this issue?

Its from gaxios, it has code for require('node:crypto') which is causing this issue

@trentm
Copy link
Contributor

trentm commented Jul 31, 2024

@architgarg95 Yes, I know it is from gaxios. Could you please show the output of npm ls gaxios and npm ls uuid in your tree. That will show me the exact versions, which helps clarify that I understand the issue.

@architgarg95
Copy link
Author

npm ls gaxios output:
└─┬ @opentelemetry/auto-instrumentations-node@0.47.1
└─┬ @opentelemetry/resource-detector-gcp@0.29.10
└─┬ gcp-metadata@6.1.0
└── gaxios@6.7.0

npm ls uuid output:
@opentelemetry/auto-instrumentations-node@0.47.1
│ └─┬ @opentelemetry/resource-detector-gcp@0.29.10
│ └─┬ gcp-metadata@6.1.0
│ └─┬ gaxios@6.7.0
│ └── uuid@10.0.0

@architgarg95
Copy link
Author

@trentm Do you know anything about this??

@trentm
Copy link
Contributor

trentm commented Aug 8, 2024

@architgarg95 Thanks for the 'npm ls ...' output. So, yes, you have hit the issue with gaxios@6.7.0 being a minor release that broke support for Node.js versions less than 14.18. I've asked (on the gaxios issue linked above) if a new release woiuld be possible. That would fix you.

Other options:

  • If you are able to control your install tree so that gaxios@6.6.0 is installed and used, that should fix it. I'm not sure if a simple npm install gaxios@6.6.0 would fix that.
  • If you are able to update to a more recent Node.js 14.x version, that would also fix it for you.

@trentm
Copy link
Contributor

trentm commented Aug 14, 2024

There is now a gaxios@6.7.1 release with a fix.

If I now install the auto-instrumentations-node package, the resulting install has gaxios@6.7.1 and uuid@9, which should now work with Node.js 14:

% npm install @opentelemetry/auto-instrumentations-node
⸨  ░░░░░░░░░░░░░░░░⸩ ⠦ fetchMetadata: sill resolveWithNewModule @types/mysql@2.15.22 checking installable status

> protobufjs@7.3.2 postinstall /Users/trentm/tmp/asdf.20240809T154923/node_modules/protobufjs
> node scripts/postinstall

npm WARN asdf.20240809t154923@1.0.0 No description
npm WARN asdf.20240809t154923@1.0.0 No repository field.

+ @opentelemetry/auto-instrumentations-node@0.49.1
added 151 packages from 152 contributors and audited 151 packages in 12.656s

9 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

% npm ls uuid
asdf.20240809t154923@1.0.0 /Users/trentm/tmp/asdf.20240809T154923
└─┬ @opentelemetry/auto-instrumentations-node@0.49.1
  └─┬ @opentelemetry/resource-detector-gcp@0.29.10
    └─┬ gcp-metadata@6.1.0
      └─┬ gaxios@6.7.1
        └── uuid@9.0.1

@trentm trentm closed this as completed Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants