Skip to content

Commit 89ed6a3

Browse files
fix(NODE-6377): Remove noResponse option
1 parent 6104c57 commit 89ed6a3

File tree

9 files changed

+17
-18
lines changed

9 files changed

+17
-18
lines changed

src/cmap/connection.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ export interface CommandOptions extends BSONSerializeOptions {
8181
/** Session to use for the operation */
8282
session?: ClientSession;
8383
documentsReturnedIn?: string;
84-
noResponse?: boolean;
8584
omitReadPreference?: boolean;
8685

8786
// TODO(NODE-2802): Currently the CommandOptions take a property willRetryWrite which is a hint
@@ -439,7 +438,7 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
439438
zlibCompressionLevel: this.description.zlibCompressionLevel
440439
});
441440

442-
if (options.noResponse || message.moreToCome) {
441+
if (message.moreToCome) {
443442
yield MongoDBResponse.empty;
444443
return;
445444
}
@@ -527,11 +526,7 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
527526
new CommandSucceededEvent(
528527
this,
529528
message,
530-
options.noResponse
531-
? undefined
532-
: message.moreToCome
533-
? { ok: 1 }
534-
: (object ??= document.toObject(bsonOptions)),
529+
message.moreToCome ? { ok: 1 } : (object ??= document.toObject(bsonOptions)),
535530
started,
536531
this.description.serverConnectionId
537532
)

src/mongo_client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ export class MongoClient extends TypedEventEmitter<MongoClientEvents> implements
628628
this,
629629
new RunAdminCommandOperation(
630630
{ endSessions },
631-
{ readPreference: ReadPreference.primaryPreferred, noResponse: true }
631+
{ readPreference: ReadPreference.primaryPreferred, writeConcern: { w: 0 } }
632632
)
633633
);
634634
} catch (error) {

src/operations/command.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ export interface CommandOperationOptions
5555
// Admin command overrides.
5656
dbName?: string;
5757
authdb?: string;
58-
noResponse?: boolean;
5958
}
6059

6160
/** @internal */

src/operations/run_command.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ import { type TODO_NODE_3286 } from '../mongo_types';
55
import type { ReadPreferenceLike } from '../read_preference';
66
import type { Server } from '../sdam/server';
77
import type { ClientSession } from '../sessions';
8+
import type { WriteConcern } from '../write_concern';
89
import { MongoDBNamespace } from '../utils';
9-
import { AbstractOperation } from './operation';
10+
import { Aspect, defineAspects, AbstractOperation } from './operation';
1011

1112
/** @public */
1213
export type RunCommandOptions = {
@@ -51,7 +52,7 @@ export class RunAdminCommandOperation<T = Document> extends AbstractOperation<T>
5152
constructor(
5253
public command: Document,
5354
public override options: RunCommandOptions & {
54-
noResponse?: boolean;
55+
writeConcern?: WriteConcern;
5556
bypassPinningCheck?: boolean;
5657
}
5758
) {
@@ -73,3 +74,7 @@ export class RunAdminCommandOperation<T = Document> extends AbstractOperation<T>
7374
return res;
7475
}
7576
}
77+
78+
defineAspects(RunAdminCommandOperation, [
79+
Aspect.WRITE_OPERATION
80+
]);

test/integration/collection-management/collection.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,15 +551,15 @@ describe('Collection', function () {
551551
}
552552
}
553553

554-
it('isCapped should return false for uncapped collections', async function () {
554+
it.only('isCapped should return false for uncapped collections', async function () {
555555
await testCapped(configuration, {
556556
config: configuration,
557557
collName: 'uncapped',
558558
opts: { capped: false }
559559
});
560560
});
561561

562-
it('isCapped should return false for collections instantiated without specifying capped', async function () {
562+
it.only('isCapped should return false for collections instantiated without specifying capped', async function () {
563563
await testCapped(configuration, { config: configuration, collName: 'uncapped2', opts: {} });
564564
});
565565

test/integration/crud/misc_cursors.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1496,7 +1496,7 @@ describe('Cursor', function () {
14961496
}
14971497
});
14981498

1499-
it('does not auto destroy streams', function (done) {
1499+
it.only('does not auto destroy streams', function (done) {
15001500
const docs = [];
15011501

15021502
for (var i = 0; i < 10; i++) {

test/integration/node-specific/mongo_client.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ describe('class MongoClient', function () {
682682
expect(result2).to.have.property('ok', 1);
683683
});
684684

685-
it('sends endSessions with noResponse set', async () => {
685+
it('sends endSessions with writeConcern w = 0 set', async () => {
686686
const session = client.startSession(); // make a session to be ended
687687
await client.db('test').command({ ping: 1 }, { session });
688688
await session.endSession();
@@ -698,7 +698,7 @@ describe('class MongoClient', function () {
698698
expect(startedEvents).to.have.lengthOf(1);
699699
expect(startedEvents[0]).to.have.property('commandName', 'endSessions');
700700
expect(endEvents).to.have.lengthOf(1);
701-
expect(endEvents[0]).to.have.property('reply', undefined); // noReponse: true
701+
expect(endEvents[0]).to.containSubset({ reply: { ok: 1 } }); // writeConcern.w = 0
702702
});
703703

704704
context('when server selection would return no servers', () => {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
import * as mock from '../../tools/mongodb-mock/index';
1616
import { filterForCommands } from '../shared';
1717

18-
describe('Write Concern', function () {
18+
describe.only('Write Concern', function () {
1919
context('when the WriteConcern is set in the uri', function () {
2020
let client;
2121
const events: CommandStartedEvent[] = [];

test/unit/cmap/connection.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ describe('new Connection()', function () {
4747

4848
const conn = await connect(options);
4949
const readSpy = sinon.spy(conn, 'readMany');
50-
await conn.command(ns('$admin.cmd'), { ping: 1 }, { noResponse: true });
50+
await conn.command(ns('$admin.cmd'), { ping: 1 }, { writeConcern: { w: 0 } });
5151
expect(readSpy).to.not.have.been.called;
5252
});
5353

0 commit comments

Comments
 (0)