diff --git a/src/sdam/server.ts b/src/sdam/server.ts index f1a0bf1d985..5325a8998c4 100644 --- a/src/sdam/server.ts +++ b/src/sdam/server.ts @@ -32,7 +32,7 @@ import { MongoNetworkTimeoutError, MongoRuntimeError, MongoServerClosedError, - type MongoServerError, + MongoServerError, needsRetryableWriteLabel } from '../error'; import type { ServerApi } from '../mongo_client'; @@ -369,7 +369,7 @@ export class Server extends TypedEventEmitter { // 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 }); } @@ -385,7 +385,7 @@ export class Server extends TypedEventEmitter { if (shouldClearPool) { error.addErrorLabel(MongoErrorLabel.ResetPool); } - markServerUnknown(this, error as MongoServerError); + markServerUnknown(this, error); process.nextTick(() => this.requestCheck()); } } @@ -488,7 +488,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; diff --git a/src/sdam/server_description.ts b/src/sdam/server_description.ts index 62fe0aaddee..0a33998a87a 100644 --- a/src/sdam/server_description.ts +++ b/src/sdam/server_description.ts @@ -1,5 +1,5 @@ import { type Document, Long, type ObjectId } from '../bson'; -import { type MongoError, MongoRuntimeError, type MongoServerError } from '../error'; +import { type MongoError, MongoRuntimeError, type MongoServerError, MongoNetworkError } from '../error'; import { arrayStrictEqual, compareObjectId, errorStrictEqual, HostAddress, now } from '../utils'; import type { ClusterTime } from './common'; import { ServerType } from './common'; @@ -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; diff --git a/src/sdam/topology_description.ts b/src/sdam/topology_description.ts index f2fafaf87b7..442b0fd4a60 100644 --- a/src/sdam/topology_description.ts +++ b/src/sdam/topology_description.ts @@ -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 { MongoError, MongoRuntimeError } from '../error'; import { compareObjectId, shuffle } from '../utils'; import { ServerType, TopologyType } from './common'; import { ServerDescription } from './server_description'; @@ -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;