From 7ade9079fa78538069604a5b42ad13ffbb80af46 Mon Sep 17 00:00:00 2001 From: Durran Jordan Date: Thu, 13 Jul 2023 21:52:08 +0200 Subject: [PATCH] feat(NODE-5190)!: remove deprecated keep alive options (#3771) --- src/cmap/connect.ts | 8 +------ src/cmap/connection.ts | 4 ---- src/connection_string.ts | 10 --------- src/mongo_client.ts | 9 -------- test/unit/connection_string.test.ts | 33 ----------------------------- test/unit/mongo_client.test.js | 4 ---- 6 files changed, 1 insertion(+), 67 deletions(-) diff --git a/src/cmap/connect.ts b/src/cmap/connect.ts index e191f72ce8..dd77c26685 100644 --- a/src/cmap/connect.ts +++ b/src/cmap/connect.ts @@ -331,15 +331,9 @@ const SOCKET_ERROR_EVENTS = new Set(SOCKET_ERROR_EVENT_LIST); function makeConnection(options: MakeConnectionOptions, _callback: Callback) { const useTLS = options.tls ?? false; - const keepAlive = options.keepAlive ?? true; - const socketTimeoutMS = options.socketTimeoutMS ?? Reflect.get(options, 'socketTimeout') ?? 0; const noDelay = options.noDelay ?? true; const connectTimeoutMS = options.connectTimeoutMS ?? 30000; const rejectUnauthorized = options.rejectUnauthorized ?? true; - const keepAliveInitialDelay = - ((options.keepAliveInitialDelay ?? 120000) > socketTimeoutMS - ? Math.round(socketTimeoutMS / 2) - : options.keepAliveInitialDelay) ?? 120000; const existingSocket = options.existingSocket; let socket: Stream; @@ -377,7 +371,7 @@ function makeConnection(options: MakeConnectionOptions, _callback: Callback { - afterEach(() => sinon.restore()); - before('ensure that `keepAlive` is deprecated', () => { - const { deprecated } = OPTIONS.keepAlive; - expect(deprecated).to.exist; - }); - context('when no value is provided', () => { - it('uses the default value', () => { - const options = parseOptions('mongodb://localhost:27017'); - expect(options).to.have.property('keepAlive', true); - }); - it('does not emit a deprecation warning', async () => { - const spy = sinon.spy(process, 'emitWarning'); - parseOptions('mongodb://localhost:27017'); - expect(spy.called).to.be.false; - }); - }); - - context('when a value is provided', () => { - it('uses the provided value', () => { - const options = parseOptions('mongodb://localhost:27017?keepAlive=false'); - expect(options).to.have.property('keepAlive', false); - }); - it('emits a deprecation warning', async () => { - const spy = sinon.spy(process, 'emitWarning'); - parseOptions('mongodb://localhost:27017?keepAlive=false'); - expect(spy.called, 'expected a warning to be emitted, but none was').to.be.true; - expect(spy.getCalls()[0].args[0]).to.match(/keepAlive is a deprecated option/); - }); - }); - }); }); diff --git a/test/unit/mongo_client.test.js b/test/unit/mongo_client.test.js index 1eb0d60f0d..c2199250f1 100644 --- a/test/unit/mongo_client.test.js +++ b/test/unit/mongo_client.test.js @@ -87,8 +87,6 @@ describe('MongoOptions', function () { ignoreUndefined: false, j: true, journal: false, - keepAlive: true, - keepAliveInitialDelay: 3, localThresholdMS: 3, maxConnecting: 5, maxIdleTimeMS: 3, @@ -578,8 +576,6 @@ describe('MongoOptions', function () { ['directconnection', false], ['forceserverobjectid', false], ['heartbeatfrequencyms', 10000], - ['keepalive', true], - ['keepaliveinitialdelay', 120000], ['localthresholdms', 15], ['maxidletimems', 0], ['maxpoolsize', 100],