Skip to content

Commit

Permalink
fix(NODE-5999): Change TopologyDescription.error type to MongoError (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
aditi-khare-mongoDB authored Mar 14, 2024
1 parent 8ab2055 commit 30432e8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/sdam/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ export class Server extends TypedEventEmitter<ServerEvents> {
// clear for the specific service id.
if (!this.loadBalanced) {
error.addErrorLabel(MongoErrorLabel.ResetPool);
markServerUnknown(this, error as MongoServerError);
markServerUnknown(this, error);
} else if (connection) {
this.pool.clear({ serviceId: connection.serviceId });
}
Expand All @@ -373,7 +373,7 @@ export class Server extends TypedEventEmitter<ServerEvents> {
if (shouldClearPool) {
error.addErrorLabel(MongoErrorLabel.ResetPool);
}
markServerUnknown(this, error as MongoServerError);
markServerUnknown(this, error);
process.nextTick(() => this.requestCheck());
}
}
Expand Down Expand Up @@ -476,7 +476,7 @@ function calculateRoundTripTime(oldRtt: number, duration: number): number {
return alpha * duration + (1 - alpha) * oldRtt;
}

function markServerUnknown(server: Server, error?: MongoServerError) {
function markServerUnknown(server: Server, error?: MongoError) {
// Load balancer servers can never be marked unknown.
if (server.loadBalanced) {
return;
Expand Down
4 changes: 2 additions & 2 deletions src/sdam/server_description.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type Document, Long, type ObjectId } from '../bson';
import { type MongoError, MongoRuntimeError, type MongoServerError } from '../error';
import { type MongoError, MongoRuntimeError } from '../error';
import { arrayStrictEqual, compareObjectId, errorStrictEqual, HostAddress, now } from '../utils';
import type { ClusterTime } from './common';
import { ServerType } from './common';
Expand Down Expand Up @@ -31,7 +31,7 @@ export type TagSet = { [key: string]: string };
/** @internal */
export interface ServerDescriptionOptions {
/** An Error used for better reporting debugging */
error?: MongoServerError;
error?: MongoError;

/** The round trip time to ping this server (in ms) */
roundTripTime?: number;
Expand Down
6 changes: 3 additions & 3 deletions src/sdam/topology_description.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ObjectId } from '../bson';
import * as WIRE_CONSTANTS from '../cmap/wire_protocol/constants';
import { MongoRuntimeError, type MongoServerError } from '../error';
import { type MongoError, MongoRuntimeError } from '../error';
import { compareObjectId, shuffle } from '../utils';
import { ServerType, TopologyType } from './common';
import { ServerDescription } from './server_description';
Expand Down Expand Up @@ -307,13 +307,13 @@ export class TopologyDescription {
);
}

get error(): MongoServerError | null {
get error(): MongoError | null {
const descriptionsWithError = Array.from(this.servers.values()).filter(
(sd: ServerDescription) => sd.error
);

if (descriptionsWithError.length > 0) {
return descriptionsWithError[0].error as MongoServerError;
return descriptionsWithError[0].error;
}

return null;
Expand Down

0 comments on commit 30432e8

Please sign in to comment.