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

Does crypto block the Node.js event loop? #2038

Closed
lffg opened this issue Jul 9, 2019 · 3 comments
Closed

Does crypto block the Node.js event loop? #2038

lffg opened this issue Jul 9, 2019 · 3 comments

Comments

@lffg
Copy link

lffg commented Jul 9, 2019

  • Node.js Version: 10.x
  • OS: OS X
  • Scope (install, code, runtime, meta, other?): Runtime
  • Module (and version) (if relevant): crypto

I recently found out that the crypto Node.js module is not asynchronous.

In my application, I am validating a JWT token on every request, so should I worry about the fact that this module is synchronous? My biggest concern is that this module could block the event loop.

Thanks in advance. :)

@addaleax
Copy link
Member

Most crypto work is synchronous, but there are a few exceptions (e.g. random bytes generation, key pair generation, PBKDF2/scrypt).

For a lot of operations, and in particular hashes, I would expect the overhead of moving tasks to a threadpool to outweigh the cost of a synchronous call.

There are some cases where this is a known issue though, see e.g. nodejs/node#28404.

@gireeshpunathil
Copy link
Member

ping @lffg - is there anything outstanding here, to be clarified?

@lffg
Copy link
Author

lffg commented Dec 20, 2019

No, thanks. Forgot to close. :)

@lffg lffg closed this as completed Dec 20, 2019
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

3 participants