File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -119,10 +119,13 @@ export async function executeOperation<
119119 const readPreference = operation . readPreference ?? ReadPreference . primary ;
120120 const inTransaction = ! ! session ?. inTransaction ( ) ;
121121
122+ const hasReadAspect = operation . hasAspect ( Aspect . READ_OPERATION ) ;
123+ const hasWriteAspect = operation . hasAspect ( Aspect . WRITE_OPERATION ) ;
124+
122125 if (
123126 inTransaction &&
124127 ! readPreference . equals ( ReadPreference . primary ) &&
125- ( operation . hasAspect ( Aspect . READ_OPERATION ) || operation . commandName === 'runCommand' )
128+ ( hasReadAspect || operation . commandName === 'runCommand' )
126129 ) {
127130 throw new MongoTransactionError (
128131 `Read preference in a transaction must be primary, not: ${ readPreference . mode } `
@@ -181,8 +184,6 @@ export async function executeOperation<
181184 supportsRetryableWrites ( server ) &&
182185 operation . canRetryWrite ;
183186
184- const hasReadAspect = operation . hasAspect ( Aspect . READ_OPERATION ) ;
185- const hasWriteAspect = operation . hasAspect ( Aspect . WRITE_OPERATION ) ;
186187 const willRetry = ( hasReadAspect && willRetryRead ) || ( hasWriteAspect && willRetryWrite ) ;
187188
188189 if ( hasWriteAspect && willRetryWrite ) {
You can’t perform that action at this time.
0 commit comments