Skip to content

Commit 583f29f

Browse files
committed
feat(AutoEncryption): improve error message for missing mongodb-client-encryption
Fixes NODE-2078
1 parent de14804 commit 583f29f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/operations/connect.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -472,14 +472,19 @@ function createTopology(mongoClient, topologyType, options, callback) {
472472
// setup for client side encryption
473473
let AutoEncrypter;
474474
try {
475-
AutoEncrypter = require('mongodb-client-encryption').AutoEncrypter;
475+
require.resolve('mongodb-client-encryption');
476476
} catch (err) {
477477
callback(
478478
new MongoError(
479479
'Auto-encryption requested, but the module is not installed. Please add `mongodb-client-encryption` as a dependency of your project'
480480
)
481481
);
482-
482+
return;
483+
}
484+
try {
485+
AutoEncrypter = require('mongodb-client-encryption').AutoEncrypter;
486+
} catch (err) {
487+
callback(err);
483488
return;
484489
}
485490

0 commit comments

Comments
 (0)