Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(NODE-4254): allow csfle to be dynamically required #3260

Merged
merged 2 commits into from
May 24, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/encrypter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,15 @@ export class Encrypter {

static checkForMongoCrypt(): void {
let mongodbClientEncryption = undefined;
// Ensure you always wrap an optional require in the try block NODE-3199
try {
// Ensure you always wrap an optional require in the try block NODE-3199
mongodbClientEncryption = require('mongodb-client-encryption');
// Note (NODE-4254): This is to get around the circular dependency between
// mongodb-client-encryption and the driver in the test scenarios.
if (process.env.MONGODB_CLIENT_ENCRYPTION_OVERRIDE) {
mongodbClientEncryption = require(process.env.MONGODB_CLIENT_ENCRYPTION_OVERRIDE);
} else {
mongodbClientEncryption = require('mongodb-client-encryption');
}
} catch (err) {
throw new MongoMissingDependencyError(
'Auto-encryption requested, but the module is not installed. ' +
Expand Down