Skip to content

Commit ba2af0e

Browse files
errors with endTransaction fixed
1 parent 304a4d6 commit ba2af0e

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

src/sessions.ts

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -417,14 +417,14 @@ export class ClientSession extends TypedEventEmitter<ClientSessionEvents> {
417417
* Commits the currently active transaction in this session.
418418
*/
419419
async commitTransaction(): Promise<void> {
420-
return await endTransaction(this, 'commitTransaction').catch(e => e);
420+
return await endTransaction(this, 'commitTransaction');
421421
}
422422

423423
/**
424424
* Aborts the currently active transaction in this session.
425425
*/
426426
async abortTransaction(): Promise<void> {
427-
return await endTransaction(this, 'abortTransaction').catch(e => e);
427+
return await endTransaction(this, 'abortTransaction');
428428
}
429429

430430
/**
@@ -733,7 +733,9 @@ async function endTransaction(
733733
}
734734
}
735735

736-
throw error;
736+
if (error != null) {
737+
throw error;
738+
}
737739
}
738740

739741
if (session.transaction.recoveryToken) {
@@ -757,15 +759,20 @@ async function endTransaction(
757759
});
758760
}
759761

760-
await executeOperation(
761-
session.client,
762-
new RunAdminCommandOperation(command, {
763-
session,
764-
readPreference: ReadPreference.primary,
765-
bypassPinningCheck: true
766-
})
767-
).catch(e => commandHandler(e));
768-
commandHandler();
762+
try {
763+
await executeOperation(
764+
session.client,
765+
new RunAdminCommandOperation(command, {
766+
session,
767+
readPreference: ReadPreference.primary,
768+
bypassPinningCheck: true
769+
})
770+
);
771+
commandHandler();
772+
} catch (e) {
773+
commandHandler(e);
774+
}
775+
return;
769776
}
770777
commandHandler(error);
771778
};

0 commit comments

Comments
 (0)