File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -792,10 +792,10 @@ export class ClientSession
792792 // timeoutContext to each async API, which know how to cancel themselves (i.e., the next retry will
793793 // abort the withTransaction call).
794794 // If CSOT is not enabled, do we still have time remaining or have we timed out?
795- const hasNotTimedOut =
796- this . timeoutContext ?. csotEnabled ( ) || now ( ) - startTime < MAX_TIMEOUT ;
795+ const hasTimedOut =
796+ ! this . timeoutContext ?. csotEnabled ( ) && now ( ) - startTime >= MAX_TIMEOUT ;
797797
798- if ( hasNotTimedOut ) {
798+ if ( ! hasTimedOut ) {
799799 if (
800800 ! isMaxTimeMSExpiredError ( commitError ) &&
801801 commitError . hasErrorLabel ( MongoErrorLabel . UnknownTransactionCommitResult )
@@ -813,9 +813,10 @@ export class ClientSession
813813 if ( commitError . hasErrorLabel ( MongoErrorLabel . TransientTransactionError ) ) {
814814 const BACKOFF_INITIAL_MS = 5 ;
815815 const BACKOFF_MAX_MS = 500 ;
816+ const BACKOFF_GROWTH = 1.5 ;
816817 const jitter = Math . random ( ) ;
817818 const backoffMS =
818- jitter * Math . min ( BACKOFF_INITIAL_MS * 1.5 ** retry , BACKOFF_MAX_MS ) ;
819+ jitter * Math . min ( BACKOFF_INITIAL_MS * BACKOFF_GROWTH ** retry , BACKOFF_MAX_MS ) ;
819820
820821 const willExceedTransactionDeadline =
821822 ( this . timeoutContext ?. csotEnabled ( ) &&
You can’t perform that action at this time.
0 commit comments