Skip to content

Commit 30432e8

Browse files
fix(NODE-5999): Change TopologyDescription.error type to MongoError (#4028)
1 parent 8ab2055 commit 30432e8

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/sdam/server.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ export class Server extends TypedEventEmitter<ServerEvents> {
357357
// clear for the specific service id.
358358
if (!this.loadBalanced) {
359359
error.addErrorLabel(MongoErrorLabel.ResetPool);
360-
markServerUnknown(this, error as MongoServerError);
360+
markServerUnknown(this, error);
361361
} else if (connection) {
362362
this.pool.clear({ serviceId: connection.serviceId });
363363
}
@@ -373,7 +373,7 @@ export class Server extends TypedEventEmitter<ServerEvents> {
373373
if (shouldClearPool) {
374374
error.addErrorLabel(MongoErrorLabel.ResetPool);
375375
}
376-
markServerUnknown(this, error as MongoServerError);
376+
markServerUnknown(this, error);
377377
process.nextTick(() => this.requestCheck());
378378
}
379379
}
@@ -476,7 +476,7 @@ function calculateRoundTripTime(oldRtt: number, duration: number): number {
476476
return alpha * duration + (1 - alpha) * oldRtt;
477477
}
478478

479-
function markServerUnknown(server: Server, error?: MongoServerError) {
479+
function markServerUnknown(server: Server, error?: MongoError) {
480480
// Load balancer servers can never be marked unknown.
481481
if (server.loadBalanced) {
482482
return;

src/sdam/server_description.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { type Document, Long, type ObjectId } from '../bson';
2-
import { type MongoError, MongoRuntimeError, type MongoServerError } from '../error';
2+
import { type MongoError, MongoRuntimeError } from '../error';
33
import { arrayStrictEqual, compareObjectId, errorStrictEqual, HostAddress, now } from '../utils';
44
import type { ClusterTime } from './common';
55
import { ServerType } from './common';
@@ -31,7 +31,7 @@ export type TagSet = { [key: string]: string };
3131
/** @internal */
3232
export interface ServerDescriptionOptions {
3333
/** An Error used for better reporting debugging */
34-
error?: MongoServerError;
34+
error?: MongoError;
3535

3636
/** The round trip time to ping this server (in ms) */
3737
roundTripTime?: number;

src/sdam/topology_description.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { ObjectId } from '../bson';
22
import * as WIRE_CONSTANTS from '../cmap/wire_protocol/constants';
3-
import { MongoRuntimeError, type MongoServerError } from '../error';
3+
import { type MongoError, MongoRuntimeError } from '../error';
44
import { compareObjectId, shuffle } from '../utils';
55
import { ServerType, TopologyType } from './common';
66
import { ServerDescription } from './server_description';
@@ -307,13 +307,13 @@ export class TopologyDescription {
307307
);
308308
}
309309

310-
get error(): MongoServerError | null {
310+
get error(): MongoError | null {
311311
const descriptionsWithError = Array.from(this.servers.values()).filter(
312312
(sd: ServerDescription) => sd.error
313313
);
314314

315315
if (descriptionsWithError.length > 0) {
316-
return descriptionsWithError[0].error as MongoServerError;
316+
return descriptionsWithError[0].error;
317317
}
318318

319319
return null;

0 commit comments

Comments
 (0)