From f0dc008ceb6db28b5c97ac700173b831ebb7b542 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Fri, 2 Dec 2022 16:01:29 +0100 Subject: [PATCH] fix(service-provider-server): pass in driver to fle addon directly COMPASS-6342 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See the ticket/source comments for details. I’ve confirmed that this fixes the bug, although the main thing to address here is probably writing an e2e test in Compass. --- .../service-provider-server/src/cli-service-provider.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/service-provider-server/src/cli-service-provider.ts b/packages/service-provider-server/src/cli-service-provider.ts index 525fc1be56..323ca9a96f 100644 --- a/packages/service-provider-server/src/cli-service-provider.ts +++ b/packages/service-provider-server/src/cli-service-provider.ts @@ -212,7 +212,13 @@ class CliServiceProvider extends ServiceProviderCore implements ServiceProvider this.baseCmdOptions = { ... DEFAULT_BASE_OPTIONS }; // currently do not have any user-specified connection-wide command options, but I imagine we will eventually this.dbcache = new WeakMap(); try { - this.fle = require('mongodb-client-encryption'); + // The .extension() call may seem unnecessary, since that is the default + // for the top-level exports from mongodb-client-encryption anyway. + // However, for the browser runtime, we externalize mongodb-client-encryption + // since it is a native addon package; that means that if 'mongodb' is + // included in the bundle, it won't be able to find it, and instead needs + // to receive it as an explicitly passed dependency. + this.fle = require('mongodb-client-encryption').extension(require('mongodb')); } catch { /* not empty */ } }