Closed
Description
Affected URL(s)
https://nodejs.org/api/crypto.html#cryptogenerateprimesize-options-callback
Description of the problem
The current documentation lists the callback
argument of crypto.generatePrime
as optional (it's surrounded by square brackets), but this is incorrect - calling the function without a callback will result in an error:
> crypto.generatePrime(3)
Uncaught:
TypeError [ERR_INVALID_ARG_TYPE]: The "callback" argument must be of type function. Received undefined
at Object.generatePrime (node:internal/crypto/random:476:3) {
code: 'ERR_INVALID_ARG_TYPE'
}
For the record, the correct way to generate a prime synchronously, without a callback, is to use the generatePrimeSync
API.