Skip to content

Commit

Permalink
fix: spelling, assertAlive always returns true
Browse files Browse the repository at this point in the history
  • Loading branch information
nbbeeken committed Mar 14, 2022
1 parent b9ed1fa commit ffba0f4
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 21 deletions.
20 changes: 0 additions & 20 deletions src/sessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,6 @@ import {

const minWireVersionForShardedTransactions = 8;

function assertAlive(session: ClientSession, callback?: Callback): boolean {
if (session.serverSession == null) {
const error = new MongoExpiredSessionError();
if (typeof callback === 'function') {
callback(error);
return false;
}

throw error;
}

return true;
}

/** @public */
export interface ClientSessionOptions {
/** Whether causal consistency should be enabled on this session */
Expand Down Expand Up @@ -393,7 +379,6 @@ export class ClientSession extends TypedEventEmitter<ClientSessionEvents> {
throw new MongoCompatibilityError('Transactions are not allowed with snapshot sessions');
}

assertAlive(this);
if (this.inTransaction()) {
throw new MongoTransactionError('Transaction already in progress');
}
Expand Down Expand Up @@ -658,11 +643,6 @@ function endTransaction(
commandName: 'abortTransaction' | 'commitTransaction',
callback: Callback<Document>
) {
if (!assertAlive(session, callback)) {
// checking result in case callback was called
return;
}

// handle any initial problematic cases
const txnState = session.transaction.state;

Expand Down
2 changes: 1 addition & 1 deletion test/unit/sessions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ describe('Sessions - unit', function () {
expect(session.clusterTime).to.eql(clusterTime);
});

it('should not acquire a serverSession inside incrementTxnNumber', () => {
it('should not acquire a serverSession inside incrementTransactionNumber', () => {
const client = new Topology(topologyHost, topologyOptions);
const sessionPool = client.s.sessionPool;
const session = new ClientSession(client, sessionPool, {});
Expand Down

0 comments on commit ffba0f4

Please sign in to comment.