-
Notifications
You must be signed in to change notification settings - Fork 28.9k
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
doc: crypto.randomBytes does not block when async #14993
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a suggestion.
doc/api/crypto.md
Outdated
@@ -1717,7 +1717,8 @@ console.log( | |||
`${buf.length} bytes of random data: ${buf.toString('hex')}`); | |||
``` | |||
|
|||
The `crypto.randomBytes()` method will block until there is sufficient entropy. | |||
The `crypto.randomBytes()` method will not generate bytes until there is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/generate bytes/complete/?
@@ -1717,7 +1717,8 @@ console.log( | |||
`${buf.length} bytes of random data: ${buf.toString('hex')}`); | |||
``` | |||
|
|||
The `crypto.randomBytes()` method will block until there is sufficient entropy. | |||
The `crypto.randomBytes()` method will not complete until there is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this only the case for the async version of this function (e.g. when a callback is passed)? How does it not block when the sync version is invoked and there is not sufficient entropy at that time? I think we should be explicit here about this difference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its the case for both versions. If its sync, it won't complete. If it's async, it won't complete. Can you suggest some other wording? I think the current wording applies equally to both, and the previous wording applied only to the sync version.
It may not return random bytes right away, but when called asynchronously it will not block. PR-URL: nodejs#14993 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
19a79ba
to
68321b5
Compare
It may not return random bytes right away, but when called asynchronously it will not block. PR-URL: nodejs/node#14993 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
It may not return random bytes right away, but when called asynchronously it will not block. PR-URL: nodejs/node#14993 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
It may not return random bytes right away, but when called asynchronously it will not block. PR-URL: #14993 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
It may not return random bytes right away, but when called asynchronously it will not block. PR-URL: #14993 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
It may not return random bytes right away, but when called asynchronously it will not block. PR-URL: #14993 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
It may not return random bytes right away, but when called
asynchronously it will not block.
Checklist
Affected core subsystem(s)
doc