Skip to content

Commit b13a851

Browse files
committed
fix: reintroduce nullish guards
1 parent 456712a commit b13a851

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/sdam/server_description.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,15 @@ export class ServerDescription {
181181
* in the {@link https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-discovery-and-monitoring.rst#serverdescription|SDAM spec}
182182
*/
183183
equals(other?: ServerDescription | null): boolean {
184+
const topologyVersionsEqual =
185+
this.topologyVersion === other?.topologyVersion ||
186+
compareTopologyVersion(this.topologyVersion, other?.topologyVersion) === 0;
187+
188+
const electionIdsEqual =
189+
this.electionId && other?.electionId != null
190+
? other.electionId && compareObjectId(this.electionId, other.electionId) === 0
191+
: this.electionId === other?.electionId;
192+
184193
return (
185194
other != null &&
186195
errorStrictEqual(this.error, other.error) &&
@@ -190,10 +199,10 @@ export class ServerDescription {
190199
tagsStrictEqual(this.tags, other.tags) &&
191200
this.setName === other.setName &&
192201
this.setVersion === other.setVersion &&
193-
compareObjectId(this.electionId, other.electionId) === 0 &&
202+
electionIdsEqual &&
194203
this.primary === other.primary &&
195204
this.logicalSessionTimeoutMinutes === other.logicalSessionTimeoutMinutes &&
196-
compareTopologyVersion(this.topologyVersion, other.topologyVersion) === 0
205+
topologyVersionsEqual
197206
);
198207
}
199208
}

0 commit comments

Comments
 (0)