Skip to content

Commit ea3b615

Browse files
committed
fix: spelling, assertAlive always returns true
1 parent 78d0ca2 commit ea3b615

File tree

2 files changed

+1
-21
lines changed

2 files changed

+1
-21
lines changed

src/sessions.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,6 @@ import type { WriteConcern } from './write_concern';
4545

4646
const minWireVersionForShardedTransactions = 8;
4747

48-
function assertAlive(session: ClientSession, callback?: Callback): boolean {
49-
if (session.serverSession == null) {
50-
const error = new MongoExpiredSessionError();
51-
if (typeof callback === 'function') {
52-
callback(error);
53-
return false;
54-
}
55-
56-
throw error;
57-
}
58-
59-
return true;
60-
}
61-
6248
/** @public */
6349
export interface ClientSessionOptions {
6450
/** Whether causal consistency should be enabled on this session */
@@ -396,7 +382,6 @@ export class ClientSession extends TypedEventEmitter<ClientSessionEvents> {
396382
throw new MongoCompatibilityError('Transactions are not allowed with snapshot sessions');
397383
}
398384

399-
assertAlive(this);
400385
if (this.inTransaction()) {
401386
throw new MongoTransactionError('Transaction already in progress');
402387
}
@@ -657,11 +642,6 @@ function attemptTransaction<TSchema>(
657642
}
658643

659644
function endTransaction(session: ClientSession, commandName: string, callback: Callback<Document>) {
660-
if (!assertAlive(session, callback)) {
661-
// checking result in case callback was called
662-
return;
663-
}
664-
665645
// handle any initial problematic cases
666646
const txnState = session.transaction.state;
667647

test/unit/sessions.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ describe('Sessions - unit', function () {
9191
expect(session.clusterTime).to.eql(clusterTime);
9292
});
9393

94-
it('should not acquire a serverSession inside incrementTxnNumber', () => {
94+
it('should not acquire a serverSession inside incrementTransactionNumber', () => {
9595
const client = new Topology(topologyHost, topologyOptions);
9696
const sessionPool = client.s.sessionPool;
9797
const session = new ClientSession(client, sessionPool, {});

0 commit comments

Comments
 (0)