Skip to content

Commit ff10bb5

Browse files
committed
remove unneeded changes
1 parent 9727233 commit ff10bb5

File tree

14 files changed

+31
-119
lines changed

14 files changed

+31
-119
lines changed

src/bulk/common.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import { makeUpdateStatement, UpdateOperation, type UpdateStatement } from '../o
2020
import type { Server } from '../sdam/server';
2121
import type { Topology } from '../sdam/topology';
2222
import type { ClientSession } from '../sessions';
23-
import { type Timeout } from '../timeout';
2423
import { maybeAddIdToDocuments } from '../utils';
2524
import {
2625
applyRetryableWrites,
@@ -875,8 +874,6 @@ export interface BulkWriteOptions extends CommandOperationOptions {
875874
forceServerObjectId?: boolean;
876875
/** Map of parameter names and values that can be accessed using $$var (requires MongoDB 5.0). */
877876
let?: Document;
878-
/** @internal */
879-
timeout?: Timeout | null;
880877
}
881878

882879
const executeCommandsAsync = promisify(executeCommands);

src/cmap/connection.ts

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import { type CancellationToken, TypedEventEmitter } from '../mongo_types';
2929
import { ReadPreference, type ReadPreferenceLike } from '../read_preference';
3030
import { ServerType } from '../sdam/common';
3131
import { applySession, type ClientSession, updateSessionFromResponse } from '../sessions';
32-
import { Timeout } from '../timeout';
3332
import {
3433
BufferPool,
3534
calculateDurationInMs,
@@ -59,7 +58,6 @@ import {
5958
type WriteProtocolMessageType
6059
} from './commands';
6160
import type { Stream } from './connect';
62-
import { type ConnectionPool } from './connection_pool';
6361
import type { ClientMetadata } from './handshake/client_metadata';
6462
import { StreamDescription, type StreamDescriptionOptions } from './stream_description';
6563
import { type CompressorName, decompressResponse } from './wire_protocol/compression';
@@ -90,8 +88,6 @@ export interface CommandOptions extends BSONSerializeOptions {
9088
writeConcern?: WriteConcern;
9189

9290
directConnection?: boolean;
93-
94-
timeout?: Timeout | null;
9591
}
9692

9793
/** @public */
@@ -184,7 +180,6 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
184180
* Once connection is established, command logging can log events (if enabled)
185181
*/
186182
public established: boolean;
187-
public pool?: ConnectionPool;
188183
/** Indicates that the connection (including underlying TCP socket) has been closed. */
189184
public closed = false;
190185

@@ -281,10 +276,6 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
281276
);
282277
}
283278

284-
private get minRoundTripTime(): number {
285-
return this.pool?.server.description.minRoundTripTime ?? 0;
286-
}
287-
288279
public markAvailable(): void {
289280
this.lastUseTime = now();
290281
}
@@ -349,10 +340,6 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
349340

350341
let clusterTime = this.clusterTime;
351342

352-
if (Timeout.is(options.timeout) && options.timeout.duration > 0) {
353-
cmd.maxTimeMS = options.timeout.getMaxTimeMS(this.minRoundTripTime);
354-
}
355-
356343
if (this.serverApi) {
357344
const { version, strict, deprecationErrors } = this.serverApi;
358345
cmd.apiVersion = version;
@@ -442,8 +429,7 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
442429
try {
443430
await this.writeCommand(message, {
444431
agreedCompressor: this.description.compressor ?? 'none',
445-
zlibCompressionLevel: this.description.zlibCompressionLevel,
446-
timeout: options.timeout
432+
zlibCompressionLevel: this.description.zlibCompressionLevel
447433
});
448434

449435
if (options.noResponse) {
@@ -453,7 +439,7 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
453439

454440
this.throwIfAborted();
455441

456-
for await (const response of this.readMany({ timeout: options.timeout })) {
442+
for await (const response of this.readMany()) {
457443
this.socket.setTimeout(0);
458444
const bson = response.parse();
459445

@@ -646,11 +632,7 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
646632
*/
647633
private async writeCommand(
648634
command: WriteProtocolMessageType,
649-
options: {
650-
agreedCompressor?: CompressorName;
651-
zlibCompressionLevel?: number;
652-
timeout?: Timeout | null;
653-
}
635+
options: { agreedCompressor?: CompressorName; zlibCompressionLevel?: number }
654636
): Promise<void> {
655637
const finalCommand =
656638
options.agreedCompressor === 'none' || !OpCompressedRequest.canCompress(command)
@@ -662,15 +644,8 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
662644

663645
const buffer = Buffer.concat(await finalCommand.toBin());
664646

665-
if (this.socket.write(buffer)) {
666-
return;
667-
}
668-
const drain = once(this.socket, 'drain');
669-
670-
if (options.timeout) {
671-
await Promise.race([drain, options.timeout]);
672-
}
673-
await drain;
647+
if (this.socket.write(buffer)) return;
648+
return await once(this.socket, 'drain');
674649
}
675650

676651
/**
@@ -682,11 +657,9 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
682657
*
683658
* Note that `for-await` loops call `return` automatically when the loop is exited.
684659
*/
685-
private async *readMany(options: {
686-
timeout?: Timeout | null;
687-
}): AsyncGenerator<OpMsgResponse | OpReply> {
660+
private async *readMany(): AsyncGenerator<OpMsgResponse | OpReply> {
688661
try {
689-
this.dataEvents = onData(this.messageStream, options);
662+
this.dataEvents = onData(this.messageStream);
690663
for await (const message of this.dataEvents) {
691664
const response = await decompressResponse(message);
692665
yield response;

src/cmap/connection_pool.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,6 @@ export class ConnectionPool extends TypedEventEmitter<ConnectionPoolEvents> {
168168
[kMetrics]: ConnectionPoolMetrics;
169169
[kProcessingWaitQueue]: boolean;
170170

171-
server: Server;
172-
173171
/**
174172
* Emitted when the connection pool is created.
175173
* @event
@@ -249,7 +247,6 @@ export class ConnectionPool extends TypedEventEmitter<ConnectionPoolEvents> {
249247

250248
this[kPoolState] = PoolState.paused;
251249
this[kServer] = server;
252-
this.server = server;
253250
this[kConnections] = new List();
254251
this[kPending] = 0;
255252
this[kCheckedOut] = new Set();

src/cmap/wire_protocol/on_data.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { type EventEmitter } from 'events';
22

3-
import { type Timeout } from '../../timeout';
43
import { List, promiseWithResolvers } from '../../utils';
54

65
/**
@@ -19,7 +18,7 @@ type PendingPromises = Omit<
1918
* Returns an AsyncIterator that iterates each 'data' event emitted from emitter.
2019
* It will reject upon an error event.
2120
*/
22-
export function onData(emitter: EventEmitter, options?: { timeout?: Timeout | null }) {
21+
export function onData(emitter: EventEmitter) {
2322
// Setup pending events and pending promise lists
2423
/**
2524
* When the caller has not yet called .next(), we store the
@@ -87,8 +86,6 @@ export function onData(emitter: EventEmitter, options?: { timeout?: Timeout | nu
8786
// Adding event handlers
8887
emitter.on('data', eventHandler);
8988
emitter.on('error', errorHandler);
90-
// eslint-disable-next-line github/no-then
91-
options?.timeout?.then(() => null, errorHandler);
9289

9390
return iterator;
9491

src/operations/bulk_write.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,7 @@ export class BulkWriteOperation extends AbstractOperation<BulkWriteResult> {
3636
): Promise<BulkWriteResult> {
3737
const coll = this.collection;
3838
const operations = this.operations;
39-
const options = {
40-
...this.options,
41-
...this.bsonOptions,
42-
readPreference: this.readPreference,
43-
timeout: this.timeout
44-
};
39+
const options = { ...this.options, ...this.bsonOptions, readPreference: this.readPreference };
4540

4641
// Create the bulk operation
4742
const bulk: BulkOperationBase =

src/operations/command.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ export abstract class CommandOperation<T> extends AbstractOperation<T> {
118118
...this.options,
119119
...this.bsonOptions,
120120
readPreference: this.readPreference,
121-
session,
122-
timeout: this.timeout
121+
session
123122
};
124123

125124
const serverWireVersion = maxWireVersion(server);

src/operations/execute_operation.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,6 @@ export async function executeOperation<
187187
}
188188

189189
try {
190-
if (operation.timeout) {
191-
return await Promise.race([operation.execute(server, session), operation.timeout]);
192-
}
193190
return await operation.execute(server, session);
194191
} catch (operationError) {
195192
if (willRetry && operationError instanceof MongoError) {
@@ -263,8 +260,7 @@ async function retryOperation<
263260
const server = await topology.selectServer(selector, {
264261
session,
265262
operationName: operation.commandName,
266-
previousServer,
267-
timeout: operation.timeout
263+
previousServer
268264
});
269265

270266
if (isWriteOperation && !supportsRetryableWrites(server)) {
@@ -274,9 +270,6 @@ async function retryOperation<
274270
}
275271

276272
try {
277-
if (operation.timeout) {
278-
return await Promise.race([operation.execute(server, session), operation.timeout]);
279-
}
280273
return await operation.execute(server, session);
281274
} catch (retryError) {
282275
if (

src/operations/find.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ export class FindOperation extends CommandOperation<Document> {
115115
...this.options,
116116
...this.bsonOptions,
117117
documentsReturnedIn: 'firstBatch',
118-
session,
119-
timeout: this.timeout
118+
session
120119
});
121120
}
122121
}

src/operations/operation.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { type BSONSerializeOptions, type Document, resolveBSONOptions } from '..
22
import { ReadPreference, type ReadPreferenceLike } from '../read_preference';
33
import type { Server } from '../sdam/server';
44
import type { ClientSession } from '../sessions';
5-
import { Timeout } from '../timeout';
65
import type { MongoDBNamespace } from '../utils';
76

87
export const Aspect = {
@@ -64,10 +63,7 @@ export abstract class AbstractOperation<TResult = any> {
6463

6564
[kSession]: ClientSession | undefined;
6665

67-
timeout?: Timeout | null;
68-
6966
constructor(options: OperationOptions = {}) {
70-
this.timeout = options.timeoutMS != null ? Timeout.expires(options.timeoutMS) : null;
7167
this.readPreference = this.hasAspect(Aspect.WRITE_OPERATION)
7268
? ReadPreference.primary
7369
: ReadPreference.fromOptions(options) ?? ReadPreference.primary;

src/operations/run_command.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ export type RunCommandOptions = {
1313
session?: ClientSession;
1414
/** The read preference */
1515
readPreference?: ReadPreferenceLike;
16-
/** @internal */
17-
timeoutMS?: number;
1816
} & BSONSerializeOptions;
1917

2018
/** @internal */
@@ -33,8 +31,7 @@ export class RunCommandOperation<T = Document> extends AbstractOperation<T> {
3331
const res: TODO_NODE_3286 = await server.command(this.ns, this.command, {
3432
...this.options,
3533
readPreference: this.readPreference,
36-
session,
37-
timeout: this.timeout
34+
session
3835
});
3936
return res;
4037
}

test/integration/client-side-operations-timeout/client_side_operations_timeout.spec.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ import { loadSpecTests } from '../../spec';
44
import { runUnifiedSuite } from '../../tools/unified-spec-runner/runner';
55

66
// TODO(NODE-5823): Implement unified runner operations and options support for CSOT
7-
describe('CSOT spec tests', function () {
7+
describe.skip('CSOT spec tests', function () {
88
runUnifiedSuite(loadSpecTests(join('client-side-operations-timeout')));
99
});

0 commit comments

Comments
 (0)