NODE: fix(cryptoHooks): propagate random hook error
@@ -289,7 +289,14 @@ bool MongoCrypt::setupCryptoHooks(mongocrypt_t* mongoCrypt, CryptoHooks* cryptoH
v8::Local<v8::Object> outBuffer = BufferFromBinaryNoCopy(out);
v8::Local<v8::Value> argv[] = {outBuffer, Nan::New(count)};
- Nan::Call(*hook, Nan::GetCurrentContext()->Global(), 2, argv);
+ v8::Local<v8::Value> defaultValue = Nan::False();
+ v8::Local<v8::Value> result = Nan::Call(*hook, Nan::GetCurrentContext()->Global(), 2, argv).FromMaybe(defaultValue);
+
+ if (!result->IsNumber()) {
+ MaybeSetCryptoHookErrorStatus(result, status);
+ return false;
+ }
+
return true;
};
