Skip to content

Commit dfc39d1

Browse files
authored
fix(NODE-3511): deprecate fullResponse and remove associated buggy code paths (#2943)
1 parent 8fc9ae1 commit dfc39d1

File tree

5 files changed

+12
-15
lines changed

5 files changed

+12
-15
lines changed

src/cmap/connection.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ const kDescription = Symbol('description');
6363
const kIsMaster = Symbol('ismaster');
6464
/** @internal */
6565
const kAutoEncrypter = Symbol('autoEncrypter');
66+
/** @internal */
67+
const kFullResult = Symbol('fullResult');
6668

6769
/** @internal */
6870
export interface QueryOptions extends BSONSerializeOptions {
@@ -81,15 +83,15 @@ export interface QueryOptions extends BSONSerializeOptions {
8183
oplogReplay?: boolean;
8284
}
8385

84-
/** @public */
86+
/** @internal */
8587
export interface CommandOptions extends BSONSerializeOptions {
8688
command?: boolean;
8789
slaveOk?: boolean;
8890
/** Specify read preference if command supports it */
8991
readPreference?: ReadPreferenceLike;
9092
raw?: boolean;
9193
monitoring?: boolean;
92-
fullResult?: boolean;
94+
[kFullResult]?: boolean;
9395
socketTimeoutMS?: number;
9496
/** Session to use for the operation */
9597
session?: ClientSession;
@@ -492,7 +494,7 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
492494
write(
493495
this,
494496
query,
495-
{ fullResult: true, ...pluckBSONSerializeOptions(options) },
497+
{ [kFullResult]: true, ...pluckBSONSerializeOptions(options) },
496498
(err, result) => {
497499
if (err || !result) return callback(err, result);
498500
if (isExplain && result.documents && result.documents[0]) {
@@ -511,7 +513,7 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
511513
options: GetMoreOptions,
512514
callback: Callback<Document>
513515
): void {
514-
const fullResult = typeof options.fullResult === 'boolean' ? options.fullResult : false;
516+
const fullResult = !!options[kFullResult];
515517
const wireVersion = maxWireVersion(this);
516518
if (!cursorId) {
517519
// TODO(NODE-3483): Replace this with a MongoCommandError
@@ -526,7 +528,7 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
526528
Object.assign(options, { ...pluckBSONSerializeOptions(options) })
527529
);
528530

529-
queryOptions.fullResult = true;
531+
queryOptions[kFullResult] = true;
530532
queryOptions.command = true;
531533
write(this, getMoreOp, queryOptions, (err, response) => {
532534
if (fullResult) return callback(err, response);
@@ -591,7 +593,7 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
591593
this.command(
592594
ns,
593595
{ killCursors: ns.collection, cursors: cursorIds },
594-
{ fullResult: true, ...options },
596+
{ [kFullResult]: true, ...options },
595597
(err, response) => {
596598
if (err || !response) return callback(err);
597599
if (response.cursorNotFound) {
@@ -774,7 +776,7 @@ function write(
774776
requestId: command.requestId,
775777
cb: callback,
776778
session: options.session,
777-
fullResult: typeof options.fullResult === 'boolean' ? options.fullResult : false,
779+
fullResult: !!options[kFullResult],
778780
noResponse: typeof options.noResponse === 'boolean' ? options.noResponse : false,
779781
documentsReturnedIn: options.documentsReturnedIn,
780782
command: !!options.command,

src/operations/command.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export interface CommandOperationOptions
3131
extends OperationOptions,
3232
WriteConcernOptions,
3333
ExplainOptions {
34-
/** Return the full server response for the command */
34+
/** @deprecated This option does nothing */
3535
fullResponse?: boolean;
3636
/** Specify a read concern and level for the collection. (only MongoDB 3.2 or higher supported) */
3737
readConcern?: ReadConcernLike;
@@ -66,7 +66,6 @@ export abstract class CommandOperation<T> extends AbstractOperation<T> {
6666
readConcern?: ReadConcern;
6767
writeConcern?: WriteConcern;
6868
explain?: Explain;
69-
fullResponse?: boolean;
7069
logger?: Logger;
7170

7271
constructor(parent?: OperationParent, options?: CommandOperationOptions) {
@@ -87,8 +86,6 @@ export abstract class CommandOperation<T> extends AbstractOperation<T> {
8786

8887
this.readConcern = ReadConcern.fromOptions(options);
8988
this.writeConcern = WriteConcern.fromOptions(options);
90-
this.fullResponse =
91-
options && typeof options.fullResponse === 'boolean' ? options.fullResponse : false;
9289

9390
// TODO(NODE-2056): make logger another "inheritable" property
9491
if (parent && parent.logger) {
@@ -169,6 +166,6 @@ export abstract class CommandOperation<T> extends AbstractOperation<T> {
169166
}
170167
}
171168

172-
server.command(this.ns, cmd, { fullResult: !!this.fullResponse, ...options }, callback);
169+
server.command(this.ns, cmd, options, callback);
173170
}
174171
}

src/operations/distinct.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export class DistinctOperation extends CommandOperation<any[]> {
8080
return;
8181
}
8282

83-
callback(undefined, this.options.fullResponse || this.explain ? result : result.values);
83+
callback(undefined, this.explain ? result : result.values);
8484
});
8585
}
8686
}

src/operations/find.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ export class FindOperation extends CommandOperation<Document> {
166166
this.ns,
167167
findCommand,
168168
{
169-
fullResult: !!this.fullResponse,
170169
...this.options,
171170
...this.bsonOptions,
172171
documentsReturnedIn: 'firstBatch',

src/operations/operation.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ export abstract class AbstractOperation<TResult = any> {
4848
cmd!: Document;
4949
readPreference: ReadPreference;
5050
server!: Server;
51-
fullResponse?: boolean;
5251
bypassPinningCheck: boolean;
5352

5453
// BSON serialization options

0 commit comments

Comments
 (0)