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 12, 2017
1 parent 503370e commit a06d129
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion doc/api/crypto.md
Expand Up @@ -1713,7 +1713,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 a06d129

Please sign in to comment.