From 97f674ea2e98a20b82fc8f75efb56ac435011720 Mon Sep 17 00:00:00 2001 From: Paula Stachova Date: Thu, 6 Nov 2025 15:34:13 +0100 Subject: [PATCH 1/2] fix: deserialize error with promoteValues --- src/cmap/connection.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/cmap/connection.ts b/src/cmap/connection.ts index ed7e8f6a0d..a26f218b47 100644 --- a/src/cmap/connection.ts +++ b/src/cmap/connection.ts @@ -499,6 +499,10 @@ export class Connection extends TypedEventEmitter { } } + private deserializeError(document: Document, bsonOptions: DeserializeOptions): Document { + return document.toObject({ ...bsonOptions, promoteValues: true }); + }; + private async *sendCommand( ns: MongoDBNamespace, command: Document, @@ -551,10 +555,10 @@ export class Connection extends TypedEventEmitter { 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) { From b2a8191bc9f98ceb239efb61a7051c127c3d4351 Mon Sep 17 00:00:00 2001 From: Paula Stachova Date: Thu, 6 Nov 2025 17:29:10 +0100 Subject: [PATCH 2/2] lint --- src/cmap/connection.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmap/connection.ts b/src/cmap/connection.ts index a26f218b47..04e3ac629d 100644 --- a/src/cmap/connection.ts +++ b/src/cmap/connection.ts @@ -501,7 +501,7 @@ export class Connection extends TypedEventEmitter { private deserializeError(document: Document, bsonOptions: DeserializeOptions): Document { return document.toObject({ ...bsonOptions, promoteValues: true }); - }; + } private async *sendCommand( ns: MongoDBNamespace,