@@ -237,6 +237,8 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
237
237
. on ( 'error' , this . onError . bind ( this ) ) ;
238
238
this . socket . on ( 'close' , this . onClose . bind ( this ) ) ;
239
239
this . socket . on ( 'timeout' , this . onTimeout . bind ( this ) ) ;
240
+
241
+ this . messageStream . pause ( ) ;
240
242
}
241
243
242
244
public get hello ( ) {
@@ -427,11 +429,8 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
427
429
) : AsyncGenerator < MongoDBResponse > {
428
430
this . throwIfAborted ( ) ;
429
431
430
- if ( typeof options . socketTimeoutMS === 'number' ) {
431
- this . socket . setTimeout ( options . socketTimeoutMS ) ;
432
- } else if ( this . socketTimeoutMS !== 0 ) {
433
- this . socket . setTimeout ( this . socketTimeoutMS ) ;
434
- }
432
+ const socketTimeoutMS = options . socketTimeoutMS ?? this . socketTimeoutMS ?? 0 ;
433
+ this . socket . setTimeout ( socketTimeoutMS ) ;
435
434
436
435
try {
437
436
await this . writeCommand ( message , {
@@ -455,11 +454,7 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
455
454
yield document ;
456
455
this . throwIfAborted ( ) ;
457
456
458
- if ( typeof options . socketTimeoutMS === 'number' ) {
459
- this . socket . setTimeout ( options . socketTimeoutMS ) ;
460
- } else if ( this . socketTimeoutMS !== 0 ) {
461
- this . socket . setTimeout ( this . socketTimeoutMS ) ;
462
- }
457
+ this . socket . setTimeout ( socketTimeoutMS ) ;
463
458
}
464
459
} finally {
465
460
this . socket . setTimeout ( 0 ) ;
0 commit comments