Skip to content

Commit 49c2b6a

Browse files
committed
fixup finally, simple if stmt
1 parent dc1264f commit 49c2b6a

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

src/operations/execute_operation.ts

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -191,28 +191,24 @@ async function executeOperationAsync<
191191
const hasReadAspect = operation.hasAspect(Aspect.READ_OPERATION);
192192
const hasWriteAspect = operation.hasAspect(Aspect.WRITE_OPERATION);
193193

194-
if ((hasReadAspect && willRetryRead) || (hasWriteAspect && willRetryWrite)) {
195-
if (hasWriteAspect && willRetryWrite) {
196-
operation.options.willRetryWrite = true;
197-
session.incrementTransactionNumber();
198-
}
194+
if (hasWriteAspect && willRetryWrite) {
195+
operation.options.willRetryWrite = true;
196+
session.incrementTransactionNumber();
199197
}
200198

201199
try {
202-
try {
203-
return await operation.executeAsync(server, session);
204-
} catch (operationError) {
205-
if ((hasReadAspect && willRetryRead) || (hasWriteAspect && willRetryWrite)) {
206-
if (operationError instanceof MongoError) {
207-
return await retryOperation(operation, operationError, {
208-
session,
209-
topology,
210-
selector
211-
});
212-
}
200+
return await operation.executeAsync(server, session);
201+
} catch (operationError) {
202+
if ((hasReadAspect && willRetryRead) || (hasWriteAspect && willRetryWrite)) {
203+
if (operationError instanceof MongoError) {
204+
return await retryOperation(operation, operationError, {
205+
session,
206+
topology,
207+
selector
208+
});
213209
}
214-
throw operationError;
215210
}
211+
throw operationError;
216212
} finally {
217213
if (session?.owner != null && session.owner === owner) {
218214
await session.endSession().catch(() => null);

0 commit comments

Comments
 (0)