File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -586,7 +586,9 @@ Socket.prototype.close = function () {
586
586
close ( ) ;
587
587
}
588
588
589
- if ( this . upgrading ) {
589
+ if ( this . writeBuffer . length ) {
590
+ this . once ( 'drain' , close ) ;
591
+ } else if ( this . upgrading ) {
590
592
// wait for upgrade to finish since we can't send packets while pausing a transport
591
593
this . once ( 'upgrade' , cleanupAndClose ) ;
592
594
this . once ( 'upgradeError' , cleanupAndClose ) ;
Original file line number Diff line number Diff line change @@ -143,5 +143,18 @@ describe('connection', function() {
143
143
} , 1200 ) ;
144
144
} ) ;
145
145
} ) ;
146
+
147
+ it ( 'should send all buffered packets if closing is deferred' , function ( done ) {
148
+ var socket = new eio . Socket ( ) ;
149
+ socket . on ( 'open' , function ( ) {
150
+ socket . on ( 'upgrading' , function ( ) {
151
+ socket . send ( 'hi' ) ;
152
+ socket . close ( ) ;
153
+ } ) . on ( 'close' , function ( ) {
154
+ expect ( socket . writeBuffer ) . to . have . length ( 0 ) ;
155
+ done ( ) ;
156
+ } ) ;
157
+ } ) ;
158
+ } ) ;
146
159
}
147
160
} ) ;
You can’t perform that action at this time.
0 commit comments