Skip to content

Commit

Permalink
doc: crypto.randomBytes does not block when async
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
sam-github authored and MylesBorins committed Sep 20, 2017
1 parent 6540e99 commit 4c26913
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion doc/api/crypto.md
Original file line number Diff line number Diff line change
Expand Up @@ -1540,7 +1540,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
sufficient entropy available.
This should normally never take longer than a few milliseconds. The only time
when generating the random bytes may conceivably block for a longer period of
time is right after boot, when the whole system is still low on entropy.
Expand Down

0 comments on commit 4c26913

Please sign in to comment.