diff --git a/packages/cli-repl/src/mongocryptd-manager.spec.ts b/packages/cli-repl/src/mongocryptd-manager.spec.ts index e756388e9c..28106527e1 100644 --- a/packages/cli-repl/src/mongocryptd-manager.spec.ts +++ b/packages/cli-repl/src/mongocryptd-manager.spec.ts @@ -51,8 +51,8 @@ describe('MongocryptdManager', () => { expect(makeManager().close().state).to.equal(null); }); - for (const otherMongocryptd of ['none', 'missing', 'broken', 'weirdlog']) { - for (const version of ['4.2', '4.4']) { + for (const otherMongocryptd of ['none', 'missing', 'broken', 'weirdlog', 'broken-after']) { + for (const version of ['4.2', '4.4']) { // This refers to the log format version for (const variant of ['withunix', 'nounix']) { // eslint-disable-next-line no-loop-func it(`spawns a working mongocryptd (${version}, ${variant}, other mongocryptd: ${otherMongocryptd})`, async() => { @@ -71,6 +71,9 @@ describe('MongocryptdManager', () => { if (otherMongocryptd === 'weirdlog') { spawnPaths.unshift([ process.execPath, path.resolve(fakeMongocryptdDir, 'weirdlog') ]); } + if (otherMongocryptd === 'broken-after') { + spawnPaths.push([ process.execPath, path.resolve(fakeMongocryptdDir, 'exit1') ]); + } expect(await makeManager().start()).to.deep.equal({ mongocryptdURI: variant === 'nounix' ? 'mongodb://localhost:27020' : @@ -79,7 +82,8 @@ describe('MongocryptdManager', () => { }); const tryspawns = events.filter(({ event }) => event === 'mongosh:mongocryptd-tryspawn'); - expect(tryspawns).to.have.lengthOf(otherMongocryptd === 'none' ? 1 : 2); + expect(tryspawns).to.have.lengthOf( + otherMongocryptd === 'none' || otherMongocryptd === 'broken-after' ? 1 : 2); }); } } diff --git a/packages/cli-repl/src/mongocryptd-manager.ts b/packages/cli-repl/src/mongocryptd-manager.ts index ef7dfa5da0..4bd6e99418 100644 --- a/packages/cli-repl/src/mongocryptd-manager.ts +++ b/packages/cli-repl/src/mongocryptd-manager.ts @@ -168,6 +168,7 @@ export class MongocryptdManager { // No UNIX socket means we're on Windows, where we have to use networking. uri = !socket ? `mongodb://localhost:${port}` : `mongodb://${encodeURIComponent(socket)}`; + break; } if (!proc || !uri) { throw lastError ?? new MongoshInternalError('Could not successfully spawn mongocryptd');