Skip to content

Commit 7785e07

Browse files
authored
docs(NODE-3481): deprecate unref
1 parent d6c201e commit 7785e07

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/db.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,10 @@ export class Db {
698698
);
699699
}
700700

701-
/** Unref all sockets */
701+
/**
702+
* Unref all sockets
703+
* @deprecated This function is deprecated and will be removed in the next major version.
704+
*/
702705
unref(): void {
703706
getTopology(this).unref();
704707
}

src/sdam/topology.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,8 +770,11 @@ export class Topology extends TypedEventEmitter<TopologyEvents> {
770770
return this.s.state === STATE_CLOSED;
771771
}
772772

773+
/**
774+
* @deprecated This function is deprecated and will be removed in the next major version.
775+
*/
773776
unref(): void {
774-
emitWarning('not implemented: `unref`');
777+
emitWarning('`unref` is a noop and will be removed in the next major version');
775778
}
776779

777780
// NOTE: There are many places in code where we explicitly check the last isMaster

test/types/mongodb.test-d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@ import { Collection } from '../../src/collection';
44
import { AggregationCursor } from '../../src/cursor/aggregation_cursor';
55
import type { FindCursor } from '../../src/cursor/find_cursor';
66
import type { Document } from 'bson';
7+
import { Db } from '../../src';
8+
import { Topology } from '../../src/sdam/topology';
79

810
// We wish to keep these APIs but continue to ensure they are marked as deprecated.
911
expectDeprecated(Collection.prototype.insert);
1012
expectDeprecated(Collection.prototype.update);
1113
expectDeprecated(Collection.prototype.remove);
1214
expectDeprecated(Collection.prototype.count);
1315
expectDeprecated(AggregationCursor.prototype.geoNear);
16+
expectDeprecated(Topology.prototype.unref);
17+
expectDeprecated(Db.prototype.unref);
1418

1519
// test mapped cursor types
1620
const client = new MongoClient('');

0 commit comments

Comments
 (0)