Skip to content

Commit 791029f

Browse files
initial commit
1 parent b70c885 commit 791029f

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

src/cmap/commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ export class OpMsgRequest {
450450

451451
// flags
452452
this.checksumPresent = false;
453-
this.moreToCome = options.moreToCome || false;
453+
this.moreToCome = options.moreToCome || options.writeConcern?.w === 0 || false;
454454
this.exhaustAllowed =
455455
typeof options.exhaustAllowed === 'boolean' ? options.exhaustAllowed : false;
456456
}

test/integration/read-write-concern/write_concern.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
import * as mock from '../../tools/mongodb-mock/index';
1212
import { filterForCommands } from '../shared';
1313

14-
describe('Write Concern', function () {
14+
describe.only('Write Concern', function () {
1515
context('when the WriteConcern is set in the uri', function () {
1616
let client;
1717
const events: CommandStartedEvent[] = [];
@@ -29,7 +29,8 @@ describe('Write Concern', function () {
2929
expect(events[0]).to.containSubset({
3030
commandName: 'insert',
3131
command: {
32-
writeConcern: { w: 0 }
32+
writeConcern: { w: 0 },
33+
moreToCome: true
3334
}
3435
});
3536
});

test/unit/commands.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import * as compression from '../../src/cmap/wire_protocol/compression';
66
import {
77
compress,
88
Compressor,
9+
Connection,
10+
MongoClient,
911
OP_MSG,
1012
OP_QUERY,
1113
OpCompressedRequest,
@@ -109,3 +111,14 @@ describe('class OpCompressedRequest', () => {
109111
}
110112
});
111113
});
114+
115+
describe.only('fire-and-forget', () => {
116+
describe('OpMsgRequest', () => {
117+
context('when writeConcern.w is 0', () => {
118+
it('moreToCome is set to true', async () => {
119+
const request = new OpMsgRequest('db', { a: 1 }, { writeConcern: { w: 0 } });
120+
expect(request.moreToCome).to.be.true;
121+
});
122+
});
123+
});
124+
});

0 commit comments

Comments
 (0)