@@ -301,8 +301,8 @@ function Socket(options) {
301
301
302
302
// Default to *not* allowing half open sockets.
303
303
options . allowHalfOpen = Boolean ( options . allowHalfOpen ) ;
304
- // For backwards compat do not emit close on destroy.
305
- options . emitClose = false ;
304
+ options . emitClose = true ;
305
+ options . errorFlagOnClose = true ;
306
306
options . autoDestroy = true ;
307
307
// Handle strings directly.
308
308
options . decodeStrings = false ;
@@ -657,28 +657,20 @@ Socket.prototype._destroy = function(exception, cb) {
657
657
if ( this . _handle ) {
658
658
if ( this !== process . stderr )
659
659
debug ( 'close handle' ) ;
660
- const isException = exception ? true : false ;
660
+ // const isException = exception ? true : false;
661
661
// `bytesRead` and `kBytesWritten` should be accessible after `.destroy()`
662
662
this [ kBytesRead ] = this . _handle . bytesRead ;
663
663
this [ kBytesWritten ] = this . _handle . bytesWritten ;
664
664
665
665
this . _handle . close ( ( ) => {
666
666
debug ( 'emit close' ) ;
667
- if ( this . _writableState ) {
668
- this . _writableState . closed = true ;
669
- }
670
- if ( this . _readableState ) {
671
- this . _readableState . closed = true ;
672
- }
673
- this . emit ( 'close' , isException ) ;
667
+ cb ( exception ) ;
674
668
} ) ;
675
669
this . _handle . onread = noop ;
676
670
this . _handle = null ;
677
671
this . _sockname = null ;
678
- cb ( exception ) ;
679
672
} else {
680
673
cb ( exception ) ;
681
- process . nextTick ( emitCloseNT , this ) ;
682
674
}
683
675
684
676
if ( this . _server ) {
0 commit comments