File tree Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ Changelog
55
66Bugfixes
77
8+ - Fixed parser not being reset in case the redis connection closed ASAP for overcoming of output buffer limits
89- Fixed parser reset if (p)message_buffer listener is attached
910
1011## v.2.6.4 - 12 Jan, 2017
Original file line number Diff line number Diff line change @@ -156,8 +156,6 @@ function RedisClient (options, stream) {
156156 this . buffers = options . return_buffers || options . detect_buffers ;
157157 this . options = options ;
158158 this . reply = 'ON' ; // Returning replies is the default
159- // Init parser
160- this . reply_parser = create_parser ( this ) ;
161159 this . create_stream ( ) ;
162160 // The listeners will not be attached right away, so let's print the deprecation message while the listener is attached
163161 this . on ( 'newListener' , function ( event ) {
@@ -230,6 +228,9 @@ function create_parser (self) {
230228RedisClient . prototype . create_stream = function ( ) {
231229 var self = this ;
232230
231+ // Init parser
232+ this . reply_parser = create_parser ( this ) ;
233+
233234 if ( this . options . stream ) {
234235 // Only add the listeners once in case of a reconnect try (that won't work)
235236 if ( this . stream ) {
Original file line number Diff line number Diff line change @@ -38,6 +38,24 @@ describe('The node_redis client', function () {
3838 client . quit ( done ) ;
3939 } ) ;
4040
41+ it ( 'reset the parser while reconnecting' , function ( done ) {
42+ var client = redis . createClient ( {
43+ retryStrategy : function ( ) {
44+ return 5 ;
45+ }
46+ } ) ;
47+ client . once ( 'reconnecting' , function ( ) {
48+ process . nextTick ( function ( ) {
49+ assert . strictEqual ( client . reply_parser . buffer , null ) ;
50+ done ( ) ;
51+ } ) ;
52+ } ) ;
53+ var partialInput = new Buffer ( '$100\r\nabcdef' ) ;
54+ client . reply_parser . execute ( partialInput ) ;
55+ assert . strictEqual ( client . reply_parser . buffer . inspect ( ) , partialInput . inspect ( ) ) ;
56+ client . stream . destroy ( ) ;
57+ } ) ;
58+
4159 helper . allTests ( function ( parser , ip , args ) {
4260
4361 describe ( 'using ' + parser + ' and ' + ip , function ( ) {
You can’t perform that action at this time.
0 commit comments