Skip to content

Commit 11a5600

Browse files
committed
fix: remove changes outside deprecations
1 parent 47c81d8 commit 11a5600

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

src/cmap/connect.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,13 +329,14 @@ const SOCKET_ERROR_EVENTS = new Set(SOCKET_ERROR_EVENT_LIST);
329329
function makeConnection(options: MakeConnectionOptions, _callback: Callback<Stream>) {
330330
const useTLS = options.tls ?? false;
331331
const keepAlive = options.keepAlive ?? true;
332+
const socketTimeoutMS = options.socketTimeoutMS ?? Reflect.get(options, 'socketTimeout') ?? 0;
332333
const noDelay = options.noDelay ?? true;
333334
const connectTimeoutMS = options.connectTimeoutMS ?? 30000;
334335
const rejectUnauthorized = options.rejectUnauthorized ?? true;
335-
// Default to delay to 300 seconds. Node automatically then sets TCP_KEEPINTVL to 1 second
336-
// which is acceptable to the recommendation of 10 seconds and also cannot be configured.
337-
// TCP_KEEPCNT is also set to 10 in Node and cannot be configured. (Recommendation is 9)
338-
const keepAliveInitialDelay = options.keepAliveInitialDelay;
336+
const keepAliveInitialDelay =
337+
((options.keepAliveInitialDelay ?? 120000) > socketTimeoutMS
338+
? Math.round(socketTimeoutMS / 2)
339+
: options.keepAliveInitialDelay) ?? 120000;
339340
const existingSocket = options.existingSocket;
340341

341342
let socket: Stream;

src/connection_string.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ export const OPTIONS = {
870870
deprecated: 'Will not be able to turn off in the future.'
871871
},
872872
keepAliveInitialDelay: {
873-
default: 300000,
873+
default: 120000,
874874
type: 'uint',
875875
deprecated: 'Will not be configurable in the future.'
876876
},

test/unit/mongo_client.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ describe('MongoOptions', function () {
610610
['forceserverobjectid', false],
611611
['heartbeatfrequencyms', 10000],
612612
['keepalive', true],
613-
['keepaliveinitialdelay', 300000],
613+
['keepaliveinitialdelay', 120000],
614614
['localthresholdms', 15],
615615
['maxidletimems', 0],
616616
['maxpoolsize', 100],

0 commit comments

Comments
 (0)