@@ -191,28 +191,24 @@ async function executeOperationAsync<
191
191
const hasReadAspect = operation . hasAspect ( Aspect . READ_OPERATION ) ;
192
192
const hasWriteAspect = operation . hasAspect ( Aspect . WRITE_OPERATION ) ;
193
193
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 ( ) ;
199
197
}
200
198
201
199
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
+ } ) ;
213
209
}
214
- throw operationError ;
215
210
}
211
+ throw operationError ;
216
212
} finally {
217
213
if ( session ?. owner != null && session . owner === owner ) {
218
214
await session . endSession ( ) . catch ( ( ) => null ) ;
0 commit comments