From 556812f2d879fc6f5585b26f6af1db6f08a19b97 Mon Sep 17 00:00:00 2001 From: Neal Beeken Date: Thu, 22 Dec 2022 13:39:39 -0500 Subject: [PATCH] feat(NODE-3482)!: remove unref (#3494) Co-authored-by: Durran Jordan --- etc/notes/CHANGES_5.0.0.md | 5 +++++ src/db.ts | 9 --------- src/sdam/topology.ts | 8 -------- test/types/mongodb.test-d.ts | 5 +---- 4 files changed, 6 insertions(+), 21 deletions(-) diff --git a/etc/notes/CHANGES_5.0.0.md b/etc/notes/CHANGES_5.0.0.md index e6a75108ad..20dae142c5 100644 --- a/etc/notes/CHANGES_5.0.0.md +++ b/etc/notes/CHANGES_5.0.0.md @@ -25,6 +25,11 @@ This means `npm` will let you know if the version of snappy you have installed i npm install --save snappy@7 ``` +### `.unref()` removed from `Db` + +The `.unref()` method was a no-op and has now been removed from the Db class. + + ### @aws-sdk/credential-providers v3.201.0 or later and optional peerDependency `@aws-sdk/credential-providers` has been added to the package.json as a peerDependency that is **optional**. diff --git a/src/db.ts b/src/db.ts index c6ab0bdc8d..73918d6d8f 100644 --- a/src/db.ts +++ b/src/db.ts @@ -44,7 +44,6 @@ import { Callback, DEFAULT_PK_FACTORY, filterOptions, - getTopology, MongoDBNamespace, resolveOptions } from './utils'; @@ -738,14 +737,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 8850063c36..261aeeac2e 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, @@ -711,13 +710,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 eb9164659e..c5511c9f9c 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);