Skip to content

Commit

Permalink
fix: Change socket timeout default to 0 (#2564)
Browse files Browse the repository at this point in the history
Socket timeout by default is infinity.

NODE-2835
  • Loading branch information
nbbeeken committed Oct 9, 2020
1 parent 98162c3 commit 7ed6dbf
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/cmap/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ function makeConnection(
: typeof options.connectTimeoutMS === 'number'
? options.connectTimeoutMS
: 30000;
const socketTimeout = typeof options.socketTimeout === 'number' ? options.socketTimeout : 360000;
const socketTimeout = typeof options.socketTimeout === 'number' ? options.socketTimeout : 0;
const rejectUnauthorized =
typeof options.rejectUnauthorized === 'boolean' ? options.rejectUnauthorized : true;

Expand Down
2 changes: 1 addition & 1 deletion src/cmap/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class Connection extends EventEmitter {
super(options);
this.id = options.id;
this.address = streamIdentifier(stream);
this.socketTimeout = options.socketTimeout ?? 360000;
this.socketTimeout = options.socketTimeout ?? 0;
this.monitorCommands = options.monitorCommands ?? options.monitorCommands;
this.closed = false;
this.destroyed = false;
Expand Down
4 changes: 2 additions & 2 deletions src/operations/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export function connect(
const finalOptions = createUnifiedOptions(urlOptions, options);

// Check if we have connection and socket timeout set
if (finalOptions.socketTimeoutMS == null) finalOptions.socketTimeoutMS = 360000;
if (finalOptions.socketTimeoutMS == null) finalOptions.socketTimeoutMS = 0;
if (finalOptions.connectTimeoutMS == null) finalOptions.connectTimeoutMS = 10000;
if (finalOptions.retryWrites == null) finalOptions.retryWrites = true;
if (finalOptions.useRecoveryToken == null) finalOptions.useRecoveryToken = true;
Expand Down Expand Up @@ -582,7 +582,7 @@ function translateOptions(options: any) {
}

// Set the socket and connection timeouts
if (options.socketTimeoutMS == null) options.socketTimeoutMS = 360000;
if (options.socketTimeoutMS == null) options.socketTimeoutMS = 0;
if (options.connectTimeoutMS == null) options.connectTimeoutMS = 10000;

const translations = {
Expand Down

0 comments on commit 7ed6dbf

Please sign in to comment.