Skip to content

Commit ed8c9d4

Browse files
committed
refactor: warn on use of deprecated SDAM events in unified mode
The `joined`, `left`, `ping`, `ha`, `all`, `fullsetup`, and `open` events are deprecated when using the unified topology. We now warn users when even listeners are attached to these events in unified mode, and documentation has been provided informing of the change.
1 parent 7e64df7 commit ed8c9d4

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

docs/reference/content/reference/unified-topology/index.md

+13
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ The unified topology no longer supports the following events:
3535
- `reconnect`
3636
- `reconnectFailed`
3737
- `attemptReconnect`
38+
- `joined`
39+
- `left`
40+
- `ping`
41+
- `ha`
42+
- `all`
43+
- `fullsetup`
44+
- `open`
3845

3946
It also deprecates the following options passed into the `MongoClient`:
4047
- `autoReconnect`
@@ -95,3 +102,9 @@ The three topology types from the "native" layer (in `lib/topologies`) primarily
95102
- There is no collaboration with the server to ensure that queued write operations only happen one time. Imagine running an `updateOne` operation which is interrupted by a network error. The operation was successfully sent to the server, but the server response was lost during the interruption, which means the operation is placed in the callback store to be retried. At the same, another microservice allows a user to update the written data. Once the original client is reconnected to the server, it automatically rexecutes the operation and updates the _newer_ data with an _older_ value.
96103

97104
The unified topology completely removes the disconnect handler, in favor of the more robust and consistent [Retryable Reads](https://github.com./mongodb/specifications/blob/master/source/retryable-reads/retryable-reads.rst) and [Retryable Writes](https://github.com./mongodb/specifications/blob/master/source/retryable-writes/retryable-writes.rst) features. Operations now will attempt execution in a server selection loop for up to `serverSelectionTimeoutMS` (default: 30s), and will retry the operation one time in the event of a [retryable error](https://github.com./mongodb/specifications/blob/master/source/retryable-writes/retryable-writes.rst#terms). All errors outside of this loop are returned to the user, since they know best what to do in these scenarios.
105+
106+
### Deprecated monitoring events
107+
108+
The `joined`, `left`, `all`, and `fullsetup` events are no longer emitted by the unified topology, primarily
109+
because their behavior is duplicated by the pre-existing SDAM monitoring events: `topologyDescriptionChanged`
110+
and `serverDescriptionChanged`. Please refer to the documentation on [Topology Monitoring]({{<relref "reference/management/sdam-monitoring/index.md">}})

lib/operations/connect.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,19 @@ function createServer(mongoClient, options, callback) {
467467
});
468468
}
469469

470-
const DEPRECATED_UNIFIED_EVENTS = new Set(['reconnect', 'reconnectFailed', 'attemptReconnect']);
470+
const DEPRECATED_UNIFIED_EVENTS = new Set([
471+
'reconnect',
472+
'reconnectFailed',
473+
'attemptReconnect',
474+
'joined',
475+
'left',
476+
'ping',
477+
'ha',
478+
'all',
479+
'fullsetup',
480+
'open'
481+
]);
482+
471483
function registerDeprecatedEventNotifiers(client) {
472484
client.on('newListener', eventName => {
473485
if (DEPRECATED_UNIFIED_EVENTS.has(eventName)) {

0 commit comments

Comments
 (0)