@@ -25,7 +25,6 @@ import {
2525import type { MongoClient , MongoOptions } from './mongo_client' ;
2626import { TypedEventEmitter } from './mongo_types' ;
2727import { executeOperation } from './operations/execute_operation' ;
28- import { RetryAttemptContext } from './operations/operation' ;
2928import { RunCommandOperation } from './operations/run_command' ;
3029import { ReadConcernLevel } from './read_concern' ;
3130import { ReadPreference } from './read_preference' ;
@@ -105,8 +104,7 @@ export interface EndSessionOptions {
105104 */
106105export class ClientSession
107106 extends TypedEventEmitter < ClientSessionEvents >
108- implements AsyncDisposable
109- {
107+ implements AsyncDisposable {
110108 /** @internal */
111109 client : MongoClient ;
112110 /** @internal */
@@ -494,23 +492,22 @@ export class ClientSession
494492 command . recoveryToken = this . transaction . recoveryToken ;
495493 }
496494
497- const retryContext = new RetryAttemptContext ( 5 ) ;
498495
499496 const operation = new RunCommandOperation ( new MongoDBNamespace ( 'admin' ) , command , {
500497 session : this ,
501498 readPreference : ReadPreference . primary ,
502499 bypassPinningCheck : true
503500 } ) ;
504- operation . attempts = retryContext ;
501+ operation . maxAttempts = 5 ;
505502
506503 const timeoutContext =
507504 this . timeoutContext ??
508505 ( typeof timeoutMS === 'number'
509506 ? TimeoutContext . create ( {
510- serverSelectionTimeoutMS : this . clientOptions . serverSelectionTimeoutMS ,
511- socketTimeoutMS : this . clientOptions . socketTimeoutMS ,
512- timeoutMS
513- } )
507+ serverSelectionTimeoutMS : this . clientOptions . serverSelectionTimeoutMS ,
508+ socketTimeoutMS : this . clientOptions . socketTimeoutMS ,
509+ timeoutMS
510+ } )
514511 : null ) ;
515512
516513 try {
@@ -531,7 +528,7 @@ export class ClientSession
531528 readPreference : ReadPreference . primary ,
532529 bypassPinningCheck : true
533530 } ) ;
534- op . attempts = retryContext ;
531+ op . maxAttempts = operation . maxAttempts ;
535532 await executeOperation ( this . client , op , timeoutContext ) ;
536533 return ;
537534 } catch ( retryCommitError ) {
@@ -612,10 +609,10 @@ export class ClientSession
612609 const timeoutContext =
613610 timeoutMS != null
614611 ? TimeoutContext . create ( {
615- timeoutMS,
616- serverSelectionTimeoutMS : this . clientOptions . serverSelectionTimeoutMS ,
617- socketTimeoutMS : this . clientOptions . socketTimeoutMS
618- } )
612+ timeoutMS,
613+ serverSelectionTimeoutMS : this . clientOptions . serverSelectionTimeoutMS ,
614+ socketTimeoutMS : this . clientOptions . socketTimeoutMS
615+ } )
619616 : null ;
620617
621618 const wc = this . transaction . options . writeConcern ?? this . clientOptions ?. writeConcern ;
@@ -728,10 +725,10 @@ export class ClientSession
728725 this . timeoutContext =
729726 timeoutMS != null
730727 ? TimeoutContext . create ( {
731- timeoutMS,
732- serverSelectionTimeoutMS : this . clientOptions . serverSelectionTimeoutMS ,
733- socketTimeoutMS : this . clientOptions . socketTimeoutMS
734- } )
728+ timeoutMS,
729+ serverSelectionTimeoutMS : this . clientOptions . serverSelectionTimeoutMS ,
730+ socketTimeoutMS : this . clientOptions . socketTimeoutMS
731+ } )
735732 : null ;
736733
737734 // 1. Record the current monotonic time, which will be used to enforce the 120-second timeout before later retry attempts.
0 commit comments