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() {
267
267
var self = this ;
268
268
269
269
handler ( function ( ) {
270
- self . processing = false ;
271
- self . flush ( ) ;
270
+ process . nextTick ( function ( ) {
271
+ self . processing = false ;
272
+ self . flush ( ) ;
273
+ } ) ;
272
274
} ) ;
273
275
} ;
274
276
Original file line number Diff line number Diff line change @@ -60,6 +60,23 @@ describe('Sender', function() {
60
60
} ) ;
61
61
sender . send ( 'hi' , { compress : true } ) ;
62
62
} ) ;
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
+ } ) ;
63
80
} ) ;
64
81
65
82
describe ( '#close' , function ( ) {
You can’t perform that action at this time.
0 commit comments