Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Change socket timeout default to 0 #2564

Merged
merged 1 commit into from
Oct 9, 2020
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -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