Skip to content

Commit c149413

Browse files
committed
test(NODE-3711): unskip transaction retry spec tests
1 parent ac44599 commit c149413

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

src/error.ts

+4
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,10 @@ const RETRYABLE_WRITE_ERROR_CODES = new Set<number>([
697697
MONGODB_ERROR_CODES.ExceededTimeLimit
698698
]);
699699

700+
export function isRetryableEndTransactionError(error: MongoError): boolean {
701+
return error.hasErrorLabel('RetryableWriteError');
702+
}
703+
700704
export function isRetryableWriteError(error: MongoError): boolean {
701705
if (error instanceof MongoWriteConcernError) {
702706
return RETRYABLE_WRITE_ERROR_CODES.has(error.result?.code ?? error.code ?? 0);

src/sessions.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
MongoError,
99
MongoInvalidArgumentError,
1010
isRetryableError,
11+
isRetryableEndTransactionError,
1112
MongoCompatibilityError,
1213
MongoNetworkError,
1314
MongoWriteConcernError,
@@ -767,7 +768,11 @@ function endTransaction(session: ClientSession, commandName: string, callback: C
767768
session.unpin();
768769
}
769770

770-
if (err && isRetryableError(err as MongoError)) {
771+
/* eslint no-console: 0 */
772+
console.log('\n\n\nerr', err);
773+
if (err && isRetryableEndTransactionError(err as MongoError)) {
774+
/* eslint no-console: 0 */
775+
console.log('retrying');
771776
// SPEC-1185: apply majority write concern when retrying commitTransaction
772777
if (command.commitTransaction) {
773778
// per txns spec, must unpin session in this case

test/functional/transactions.test.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,10 @@ const SKIP_TESTS = [
111111

112112
// Will be implemented as part of NODE-2034
113113
'Client side error in command starting transaction',
114-
'Client side error when transaction is in progress',
115-
116-
// Will be implemented as part of NODE-2538
117-
'abortTransaction only retries once with RetryableWriteError from server',
118-
'abortTransaction does not retry without RetryableWriteError label',
119-
'commitTransaction does not retry error without RetryableWriteError label',
120-
'commitTransaction retries once with RetryableWriteError from server'
114+
'Client side error when transaction is in progress'
121115
];
122116

123-
describe('Transactions Spec Legacy Tests', function () {
117+
describe.only('Transactions Spec Legacy Tests', function () {
124118
const testContext = new TransactionsRunnerContext();
125119
const suitesToRun = [{ name: 'spec tests', specPath: path.join('transactions', 'legacy') }];
126120
// Note: convenient-api tests are skipped for serverless

0 commit comments

Comments
 (0)