From a3aefdd431838a5a29a395ed368554647214ef6d Mon Sep 17 00:00:00 2001 From: Neal Beeken Date: Tue, 20 Dec 2022 16:29:46 -0500 Subject: [PATCH 1/2] feat(NODE-3482)!: remove unref --- etc/notes/CHANGES_5.0.0.md | 21 +++++++++++++++++++++ src/db.ts | 8 -------- src/sdam/topology.ts | 7 ------- test/types/mongodb.test-d.ts | 5 +---- 4 files changed, 22 insertions(+), 19 deletions(-) create mode 100644 etc/notes/CHANGES_5.0.0.md diff --git a/etc/notes/CHANGES_5.0.0.md b/etc/notes/CHANGES_5.0.0.md new file mode 100644 index 00000000000..2fc244fc133 --- /dev/null +++ b/etc/notes/CHANGES_5.0.0.md @@ -0,0 +1,21 @@ +# Changes in v5 + +## TOC + +- TODO + +## About + +The following is a detailed collection of the changes in the major v5 release of the mongodb package for Node.js. + + + +## Changes + +### `.unref()` removed from `Db` + +The `.unref()` method was a no-op and has now been removed from the Db class. diff --git a/src/db.ts b/src/db.ts index c6ab0bdc8d5..e3785ed0785 100644 --- a/src/db.ts +++ b/src/db.ts @@ -738,14 +738,6 @@ export class Db { ); } - /** - * Unref all sockets - * @deprecated This function is deprecated and will be removed in the next major version. - */ - unref(): void { - getTopology(this).unref(); - } - /** * Create a new Change Stream, watching for new changes (insertions, updates, * replacements, deletions, and invalidations) in this database. Will ignore all diff --git a/src/sdam/topology.ts b/src/sdam/topology.ts index 8850063c368..3d56d32d14b 100644 --- a/src/sdam/topology.ts +++ b/src/sdam/topology.ts @@ -711,13 +711,6 @@ export class Topology extends TypedEventEmitter { return this.s.state === STATE_CLOSED; } - /** - * @deprecated This function is deprecated and will be removed in the next major version. - */ - unref(): void { - emitWarning('`unref` is a noop and will be removed in the next major version'); - } - // NOTE: There are many places in code where we explicitly check the last hello // to do feature support detection. This should be done any other way, but for // now we will just return the first hello seen, which should suffice. diff --git a/test/types/mongodb.test-d.ts b/test/types/mongodb.test-d.ts index fe75b1e223b..5c842b3e138 100644 --- a/test/types/mongodb.test-d.ts +++ b/test/types/mongodb.test-d.ts @@ -1,14 +1,13 @@ import type { Document } from 'bson'; import { expectDeprecated, expectError, expectNotDeprecated, expectType } from 'tsd'; -import { Db, WithId, WriteConcern, WriteConcernSettings } from '../../src'; +import type { WithId, WriteConcern, WriteConcernSettings } from '../../src'; import * as MongoDBDriver from '../../src'; import type { ChangeStreamDocument } from '../../src/change_stream'; import { Collection } from '../../src/collection'; import type { AggregationCursor } from '../../src/cursor/aggregation_cursor'; import { FindCursor } from '../../src/cursor/find_cursor'; import { MongoClient } from '../../src/mongo_client'; -import { Topology } from '../../src/sdam/topology'; // We wish to keep these APIs but continue to ensure they are marked as deprecated. expectDeprecated(Collection.prototype.insert); @@ -17,8 +16,6 @@ expectDeprecated(Collection.prototype.remove); expectDeprecated(Collection.prototype.count); expectDeprecated(Collection.prototype.mapReduce); expectDeprecated(FindCursor.prototype.count); -expectDeprecated(Topology.prototype.unref); -expectDeprecated(Db.prototype.unref); expectDeprecated(MongoDBDriver.ObjectID); expectNotDeprecated(MongoDBDriver.ObjectId); From 15a5b1a6e5c79d7c9e9c146192b588ddb9216816 Mon Sep 17 00:00:00 2001 From: Neal Beeken Date: Wed, 21 Dec 2022 11:02:06 -0500 Subject: [PATCH 2/2] fix: lint --- src/db.ts | 1 - src/sdam/topology.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/src/db.ts b/src/db.ts index e3785ed0785..73918d6d8f7 100644 --- a/src/db.ts +++ b/src/db.ts @@ -44,7 +44,6 @@ import { Callback, DEFAULT_PK_FACTORY, filterOptions, - getTopology, MongoDBNamespace, resolveOptions } from './utils'; diff --git a/src/sdam/topology.ts b/src/sdam/topology.ts index 3d56d32d14b..261aeeac2e4 100644 --- a/src/sdam/topology.ts +++ b/src/sdam/topology.ts @@ -39,7 +39,6 @@ import type { Transaction } from '../transactions'; import { Callback, ClientMetadata, - emitWarning, EventEmitterWithState, HostAddress, List,