@@ -240,14 +240,14 @@ class Server extends EventEmitter {
240
240
}
241
241
242
242
wireProtocol . command ( this , ns , cmd , options , ( err , result ) => {
243
- if ( err && err instanceof MongoNetworkError ) {
244
- if ( options . session ) {
243
+ if ( err ) {
244
+ if ( options . session && err instanceof MongoNetworkError ) {
245
245
options . session . serverSession . isDirty = true ;
246
246
}
247
- }
248
247
249
- if ( err && isSDAMUnrecoverableError ( err ) ) {
250
- this . emit ( 'error' , err ) ;
248
+ if ( isSDAMUnrecoverableError ( err ) ) {
249
+ this . emit ( 'error' , err ) ;
250
+ }
251
251
}
252
252
253
253
callback ( err , result ) ;
@@ -264,14 +264,14 @@ class Server extends EventEmitter {
264
264
*/
265
265
query ( ns , cmd , cursorState , options , callback ) {
266
266
wireProtocol . query ( this , ns , cmd , cursorState , options , ( err , result ) => {
267
- if ( err && err instanceof MongoNetworkError ) {
268
- if ( options . session ) {
267
+ if ( err ) {
268
+ if ( options . session && err instanceof MongoNetworkError ) {
269
269
options . session . serverSession . isDirty = true ;
270
270
}
271
- }
272
271
273
- if ( err && isSDAMUnrecoverableError ( err ) ) {
274
- this . emit ( 'error' , err ) ;
272
+ if ( isSDAMUnrecoverableError ( err ) ) {
273
+ this . emit ( 'error' , err ) ;
274
+ }
275
275
}
276
276
277
277
callback ( err , result ) ;
@@ -288,14 +288,14 @@ class Server extends EventEmitter {
288
288
*/
289
289
getMore ( ns , cursorState , batchSize , options , callback ) {
290
290
wireProtocol . getMore ( this , ns , cursorState , batchSize , options , ( err , result ) => {
291
- if ( err && err instanceof MongoNetworkError ) {
292
- if ( options . session ) {
291
+ if ( err ) {
292
+ if ( options . session && err instanceof MongoNetworkError ) {
293
293
options . session . serverSession . isDirty = true ;
294
294
}
295
- }
296
295
297
- if ( err && isSDAMUnrecoverableError ( err ) ) {
298
- this . emit ( 'error' , err ) ;
296
+ if ( isSDAMUnrecoverableError ( err ) ) {
297
+ this . emit ( 'error' , err ) ;
298
+ }
299
299
}
300
300
301
301
callback ( err , result ) ;
@@ -424,14 +424,14 @@ function executeWriteOperation(args, options, callback) {
424
424
}
425
425
426
426
return wireProtocol [ op ] ( server , ns , ops , options , ( err , result ) => {
427
- if ( err && err instanceof MongoNetworkError ) {
428
- if ( options . session ) {
427
+ if ( err ) {
428
+ if ( options . session && err instanceof MongoNetworkError ) {
429
429
options . session . serverSession . isDirty = true ;
430
430
}
431
- }
432
431
433
- if ( err && isSDAMUnrecoverableError ( err ) ) {
434
- server . emit ( 'error' , err ) ;
432
+ if ( isSDAMUnrecoverableError ( err ) ) {
433
+ server . emit ( 'error' , err ) ;
434
+ }
435
435
}
436
436
437
437
callback ( err , result ) ;
0 commit comments