Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/cmap/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,10 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
}
}

private deserializeError(document: Document, bsonOptions: DeserializeOptions): Document {
return document.toObject({ ...bsonOptions, promoteValues: true });
}

private async *sendCommand(
ns: MongoDBNamespace,
command: Document,
Expand Down Expand Up @@ -551,10 +555,10 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
if (document.ok === 0) {
if (options.timeoutContext?.csotEnabled() && document.isMaxTimeExpiredError) {
throw new MongoOperationTimeoutError('Server reported a timeout error', {
cause: new MongoServerError((object ??= document.toObject(bsonOptions)))
cause: new MongoServerError((object ??= this.deserializeError(document, bsonOptions)))
});
}
throw new MongoServerError((object ??= document.toObject(bsonOptions)));
throw new MongoServerError((object ??= this.deserializeError(document, bsonOptions)));
}

if (this.shouldEmitAndLogCommand) {
Expand Down