Skip to content

Commit 82fa338

Browse files
expanded types to MongoError to support the diff error types
1 parent 2bbe020 commit 82fa338

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/sdam/server.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import {
3232
MongoNetworkTimeoutError,
3333
MongoRuntimeError,
3434
MongoServerClosedError,
35-
type MongoServerError,
35+
MongoServerError,
3636
needsRetryableWriteLabel
3737
} from '../error';
3838
import type { ServerApi } from '../mongo_client';
@@ -369,7 +369,7 @@ export class Server extends TypedEventEmitter<ServerEvents> {
369369
// clear for the specific service id.
370370
if (!this.loadBalanced) {
371371
error.addErrorLabel(MongoErrorLabel.ResetPool);
372-
markServerUnknown(this, error as MongoServerError);
372+
markServerUnknown(this, error);
373373
} else if (connection) {
374374
this.pool.clear({ serviceId: connection.serviceId });
375375
}
@@ -385,7 +385,7 @@ export class Server extends TypedEventEmitter<ServerEvents> {
385385
if (shouldClearPool) {
386386
error.addErrorLabel(MongoErrorLabel.ResetPool);
387387
}
388-
markServerUnknown(this, error as MongoServerError);
388+
markServerUnknown(this, error);
389389
process.nextTick(() => this.requestCheck());
390390
}
391391
}
@@ -488,7 +488,7 @@ function calculateRoundTripTime(oldRtt: number, duration: number): number {
488488
return alpha * duration + (1 - alpha) * oldRtt;
489489
}
490490

491-
function markServerUnknown(server: Server, error?: MongoServerError) {
491+
function markServerUnknown(server: Server, error?: MongoError) {
492492
// Load balancer servers can never be marked unknown.
493493
if (server.loadBalanced) {
494494
return;

src/sdam/server_description.ts

Lines changed: 2 additions & 2 deletions
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, type MongoServerError, MongoNetworkError } 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

Lines changed: 3 additions & 3 deletions
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 { 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)