File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -267,8 +267,10 @@ Sender.prototype.flush = function() {
267267 var self = this ;
268268
269269 handler ( function ( ) {
270- self . processing = false ;
271- self . flush ( ) ;
270+ process . nextTick ( function ( ) {
271+ self . processing = false ;
272+ self . flush ( ) ;
273+ } ) ;
272274 } ) ;
273275} ;
274276
Original file line number Diff line number Diff line change @@ -60,6 +60,23 @@ describe('Sender', function() {
6060 } ) ;
6161 sender . send ( 'hi' , { compress : true } ) ;
6262 } ) ;
63+
64+ it ( 'handles many send calls while processing without crashing on flush' , function ( done ) {
65+ var count = 0 ;
66+ var sender = new Sender ( {
67+ write : function ( ) {
68+ if ( ++ count > 10000 ) return done ( ) ;
69+ }
70+ } ) ;
71+
72+ for ( var i = 0 ; i < 10000 ; i ++ ) {
73+ sender . processing = true ;
74+ sender . send ( 'hi' , { compress : false , fin : true } ) ;
75+ }
76+
77+ sender . processing = false ;
78+ sender . send ( 'hi' , { compress : false , fin : true } ) ;
79+ } ) ;
6380 } ) ;
6481
6582 describe ( '#close' , function ( ) {
You can’t perform that action at this time.
0 commit comments