diff --git a/src/cmap/connection.ts b/src/cmap/connection.ts index 1c46091292f..4bcb4850e5c 100644 --- a/src/cmap/connection.ts +++ b/src/cmap/connection.ts @@ -93,6 +93,9 @@ export interface CommandOptions extends BSONSerializeOptions { writeConcern?: WriteConcern; directConnection?: boolean; + + // Triggers fire-and-forget protocol for commands that don't support WriteConcern + moreToCome?: boolean; } /** @public */ diff --git a/test/integration/connection-monitoring-and-pooling/connection.test.ts b/test/integration/connection-monitoring-and-pooling/connection.test.ts index 1192dfdbcd4..e0b21c2f54b 100644 --- a/test/integration/connection-monitoring-and-pooling/connection.test.ts +++ b/test/integration/connection-monitoring-and-pooling/connection.test.ts @@ -144,6 +144,21 @@ describe('Connection', function () { } } }); + + it('supports fire-and-forget messages', async function () { + const options: ConnectionOptions = { + ...commonConnectOptions, + connectionType: Connection, + ...this.configuration.options, + metadata: makeClientMetadata({ driverInfo: {} }), + extendedMetadata: addContainerMetadata(makeClientMetadata({ driverInfo: {} })) + }; + + const conn = await connect(options); + const readSpy = sinon.spy(conn, 'readMany'); + await conn.command(ns('$admin.cmd'), { ping: 1 }, { moreToCome: true }); + expect(readSpy).to.not.have.been.called; + }); }); describe('Connection - functional', function () { diff --git a/test/integration/read-write-concern/write_concern.test.ts b/test/integration/read-write-concern/write_concern.test.ts index 4f1f7df8097..9db7269b89f 100644 --- a/test/integration/read-write-concern/write_concern.test.ts +++ b/test/integration/read-write-concern/write_concern.test.ts @@ -173,7 +173,7 @@ describe('Write Concern', function () { }); }); - describe.only('fire-and-forget protocol', function () { + describe('fire-and-forget protocol', function () { context('when writeConcern = 0 and OP_MSG is used', function () { const writeOperations: { name: string; command: any; expectedReturnVal: any }[] = [ { diff --git a/test/unit/cmap/connection.test.ts b/test/unit/cmap/connection.test.ts index 616b9372259..639de5a0817 100644 --- a/test/unit/cmap/connection.test.ts +++ b/test/unit/cmap/connection.test.ts @@ -28,29 +28,6 @@ describe('new Connection()', function () { before(() => mock.createServer().then(s => (server = s))); - it.only('supports fire-and-forget messages', async function () { - server.setMessageHandler(request => { - const doc = request.document; - if (isHello(doc)) { - request.reply(mock.HELLO); - } - - // black hole all other requests - }); - - const options = { - ...connectionOptionsDefaults, - connectionType: Connection, - hostAddress: server.hostAddress(), - authProviders: new MongoClientAuthProviders() - }; - - const conn = await connect(options); - const readSpy = sinon.spy(conn, 'readMany'); - await conn.command(ns('$admin.cmd'), { ping: 1 }, { moreToCome: true }); - expect(readSpy).to.not.have.been.called; - }); - it('destroys streams which time out', async function () { server.setMessageHandler(request => { const doc = request.document; diff --git a/test/unit/collection.test.ts b/test/unit/collection.test.ts index a6f40e7783b..b050e69dc92 100644 --- a/test/unit/collection.test.ts +++ b/test/unit/collection.test.ts @@ -15,7 +15,7 @@ describe('Collection', function () { }); context('#createIndex', () => { - it.only('should error when createIndex fails', function (done) { + it('should error when createIndex fails', function (done) { const ERROR_RESPONSE = { ok: 0, errmsg: