File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -750,7 +750,6 @@ function socketOnClose () {
750
750
const websocket = this [ kWebSocket ] ;
751
751
752
752
this . removeListener ( 'close' , socketOnClose ) ;
753
- this . removeListener ( 'data' , socketOnData ) ;
754
753
this . removeListener ( 'end' , socketOnEnd ) ;
755
754
this [ kWebSocket ] = undefined ;
756
755
@@ -760,11 +759,16 @@ function socketOnClose () {
760
759
// The close frame might not have been received or the `'end'` event emitted,
761
760
// for example, if the socket was destroyed due to an error. Ensure that the
762
761
// `receiver` stream is closed after writing any remaining buffered data to
763
- // it.
762
+ // it. If the readable side of the socket is in flowing mode then there is no
763
+ // buffered data as everything has been already written and `readable.read()`
764
+ // will return `null`. If instead, the socket is paused, any possible buffered
765
+ // data will be read as a single chunk and emitted synchronously in a single
766
+ // `'data'` event.
764
767
//
765
768
websocket . _socket . read ( ) ;
766
769
websocket . _receiver . end ( ) ;
767
770
771
+ this . removeListener ( 'data' , socketOnData ) ;
768
772
clearTimeout ( websocket . _closeTimer ) ;
769
773
770
774
if (
You can’t perform that action at this time.
0 commit comments