From 7ed6dbf7d541a10513f3bd93f1c415ed0ced1b83 Mon Sep 17 00:00:00 2001 From: Neal Beeken Date: Fri, 9 Oct 2020 11:52:15 -0400 Subject: [PATCH] fix: Change socket timeout default to 0 (#2564) Socket timeout by default is infinity. NODE-2835 --- src/cmap/connect.ts | 2 +- src/cmap/connection.ts | 2 +- src/operations/connect.ts | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cmap/connect.ts b/src/cmap/connect.ts index 9886580b09..077385b549 100644 --- a/src/cmap/connect.ts +++ b/src/cmap/connect.ts @@ -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; diff --git a/src/cmap/connection.ts b/src/cmap/connection.ts index 597e8a83be..e9517896a0 100644 --- a/src/cmap/connection.ts +++ b/src/cmap/connection.ts @@ -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; diff --git a/src/operations/connect.ts b/src/operations/connect.ts index 8d8e5b4c15..85700deb64 100644 --- a/src/operations/connect.ts +++ b/src/operations/connect.ts @@ -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; @@ -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 = {