@@ -237,6 +237,8 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
237237 . on ( 'error' , this . onError . bind ( this ) ) ;
238238 this . socket . on ( 'close' , this . onClose . bind ( this ) ) ;
239239 this . socket . on ( 'timeout' , this . onTimeout . bind ( this ) ) ;
240+
241+ this . messageStream . pause ( ) ;
240242 }
241243
242244 public get hello ( ) {
@@ -427,11 +429,8 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
427429 ) : AsyncGenerator < MongoDBResponse > {
428430 this . throwIfAborted ( ) ;
429431
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 ) ;
435434
436435 try {
437436 await this . writeCommand ( message , {
@@ -455,11 +454,7 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
455454 yield document ;
456455 this . throwIfAborted ( ) ;
457456
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 ) ;
463458 }
464459 } finally {
465460 this . socket . setTimeout ( 0 ) ;
0 commit comments