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

lib: useless information in no crypto error stack #37593

Open
jasnell opened this issue Mar 3, 2021 · 1 comment
Open

lib: useless information in no crypto error stack #37593

jasnell opened this issue Mar 3, 2021 · 1 comment
Labels
crypto Issues and PRs related to the crypto subsystem. errors Issues and PRs related to JavaScript errors originated in Node.js core.

Comments

@jasnell
Copy link
Member

jasnell commented Mar 3, 2021

Just noting this to get back around to it later... the no crypto support error stack is a bit unfortunate as it contains internal details that just aren't helpful for the user:

Really, anything above the node:crypto frame is useless information in these stacks (commonjs or ESM)

> require('crypto')
Uncaught Error [ERR_NO_CRYPTO]: Node.js is not compiled with OpenSSL crypto support
    at new NodeError (node:internal/errors:329:5)
    at assertCrypto (node:internal/util:128:11)
    at node:crypto:36:1
    at NativeModule.compileForInternalLoader (node:internal/bootstrap/loaders:283:7)
    at NativeModule.compileForPublicLoader (node:internal/bootstrap/loaders:225:10)
    at loadNativeModule (node:internal/modules/cjs/helpers:39:9)
    at Function.Module._load (node:internal/modules/cjs/loader:787:15)
    at Module.require (node:internal/modules/cjs/loader:999:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at REPL1:1:1 {
  code: 'ERR_NO_CRYPTO'
}
> .exit
root@DESKTOP-5KK9VIR:~/node/node-check# ./node ../tmp/a.mjs
node:internal/process/esm_loader:74
    internalBinding('errors').triggerUncaughtException(
                              ^

Error [ERR_NO_CRYPTO]: Node.js is not compiled with OpenSSL crypto support
    at new NodeError (node:internal/errors:329:5)
    at assertCrypto (node:internal/util:128:11)
    at node:crypto:36:1
    at NativeModule.compileForInternalLoader (node:internal/bootstrap/loaders:283:7)
    at NativeModule.compileForPublicLoader (node:internal/bootstrap/loaders:225:10)
    at loadNativeModule (node:internal/modules/cjs/helpers:39:9)
    at Loader.builtinStrategy (node:internal/modules/esm/translators:285:18)
    at new ModuleJob (node:internal/modules/esm/module_job:44:26)
    at Loader.getModuleJob (node:internal/modules/esm/loader:246:11)
    at async ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:59:21) {
  code: 'ERR_NO_CRYPTO'
}
@jasnell
Copy link
Member Author

jasnell commented Mar 3, 2021

I would really go so far as to argue that our approach to throwing the error on load here is unfortunate and should change, largely because there is no equivalent way to catch the error when using ESM. If the module is there, we should allow it to load with the expected API surface but have the functions disabled when crypto support is not included. OR, we should allow the module to load with none of the actual APIs present.

@targos targos added crypto Issues and PRs related to the crypto subsystem. errors Issues and PRs related to JavaScript errors originated in Node.js core. labels Mar 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crypto Issues and PRs related to the crypto subsystem. errors Issues and PRs related to JavaScript errors originated in Node.js core.
Projects
None yet
Development

No branches or pull requests

2 participants