File tree 1 file changed +4
-3
lines changed
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<
119
119
const readPreference = operation . readPreference ?? ReadPreference . primary ;
120
120
const inTransaction = ! ! session ?. inTransaction ( ) ;
121
121
122
+ const hasReadAspect = operation . hasAspect ( Aspect . READ_OPERATION ) ;
123
+ const hasWriteAspect = operation . hasAspect ( Aspect . WRITE_OPERATION ) ;
124
+
122
125
if (
123
126
inTransaction &&
124
127
! readPreference . equals ( ReadPreference . primary ) &&
125
- ( operation . hasAspect ( Aspect . READ_OPERATION ) || operation . commandName === 'runCommand' )
128
+ ( hasReadAspect || operation . commandName === 'runCommand' )
126
129
) {
127
130
throw new MongoTransactionError (
128
131
`Read preference in a transaction must be primary, not: ${ readPreference . mode } `
@@ -181,8 +184,6 @@ export async function executeOperation<
181
184
supportsRetryableWrites ( server ) &&
182
185
operation . canRetryWrite ;
183
186
184
- const hasReadAspect = operation . hasAspect ( Aspect . READ_OPERATION ) ;
185
- const hasWriteAspect = operation . hasAspect ( Aspect . WRITE_OPERATION ) ;
186
187
const willRetry = ( hasReadAspect && willRetryRead ) || ( hasWriteAspect && willRetryWrite ) ;
187
188
188
189
if ( hasWriteAspect && willRetryWrite ) {
You can’t perform that action at this time.
0 commit comments