diff --git a/lib/internal/crypto/random.js b/lib/internal/crypto/random.js index c45d53c796d26a..8812120091f930 100644 --- a/lib/internal/crypto/random.js +++ b/lib/internal/crypto/random.js @@ -102,7 +102,7 @@ function randomBytes(size, callback) { // Keep the callback as a regular function so this is propagated. randomFill(buf.buffer, 0, size, function(error) { - if (error) FunctionPrototypeCall(callback, this, error); + if (error) return FunctionPrototypeCall(callback, this, error); FunctionPrototypeCall(callback, this, null, buf); }); }