Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cmap/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ function makeConnection(options: MakeConnectionOptions, _callback: Callback<Stre
}
}

socket.setTimeout(socketTimeoutMS);
socket.setTimeout(0);
callback(undefined, socket);
}

Expand Down
9 changes: 5 additions & 4 deletions src/cmap/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,8 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
this[kDelayedTimeoutId] = null;
}

this[kStream].setTimeout(0);

// always emit the message, in case we are streaming
this.emit('message', message);
let operationDescription = this[kQueue].get(message.responseTo);
Expand Down Expand Up @@ -356,8 +358,6 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
// back in the queue with the correct requestId and will resolve not being able
// to find the next one via the responseTo of the next streaming hello.
this[kQueue].set(message.requestId, operationDescription);
} else if (operationDescription.socketTimeoutOverride) {
this[kStream].setTimeout(this.socketTimeoutMS);
}

try {
Expand Down Expand Up @@ -681,8 +681,9 @@ function write(
}

if (typeof options.socketTimeoutMS === 'number') {
operationDescription.socketTimeoutOverride = true;
conn[kStream].setTimeout(options.socketTimeoutMS);
} else if (conn.socketTimeoutMS !== 0) {
conn[kStream].setTimeout(conn.socketTimeoutMS);
}

// if command monitoring is enabled we need to modify the callback here
Expand All @@ -692,7 +693,7 @@ function write(
operationDescription.started = now();
operationDescription.cb = (err, reply) => {
// Command monitoring spec states that if ok is 1, then we must always emit
// a command suceeded event, even if there's an error. Write concern errors
// a command succeeded event, even if there's an error. Write concern errors
// will have an ok: 1 in their reply.
if (err && reply?.ok !== 1) {
conn.emit(
Expand Down
1 change: 0 additions & 1 deletion src/cmap/message_stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export interface OperationDescription extends BSONSerializeOptions {
raw: boolean;
requestId: number;
session?: ClientSession;
socketTimeoutOverride?: boolean;
agreedCompressor?: CompressorName;
zlibCompressionLevel?: number;
$clusterTime?: Document;
Expand Down
188 changes: 0 additions & 188 deletions test/unit/cmap/connect.test.js

This file was deleted.

Loading