File tree 3 files changed +22
-2
lines changed 3 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ Changelog
5
5
6
6
Bugfixes
7
7
8
+ - Fixed parser not being reset in case the redis connection closed ASAP for overcoming of output buffer limits
8
9
- Fixed parser reset if (p)message_buffer listener is attached
9
10
10
11
## 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) {
156
156
this . buffers = options . return_buffers || options . detect_buffers ;
157
157
this . options = options ;
158
158
this . reply = 'ON' ; // Returning replies is the default
159
- // Init parser
160
- this . reply_parser = create_parser ( this ) ;
161
159
this . create_stream ( ) ;
162
160
// The listeners will not be attached right away, so let's print the deprecation message while the listener is attached
163
161
this . on ( 'newListener' , function ( event ) {
@@ -230,6 +228,9 @@ function create_parser (self) {
230
228
RedisClient . prototype . create_stream = function ( ) {
231
229
var self = this ;
232
230
231
+ // Init parser
232
+ this . reply_parser = create_parser ( this ) ;
233
+
233
234
if ( this . options . stream ) {
234
235
// Only add the listeners once in case of a reconnect try (that won't work)
235
236
if ( this . stream ) {
Original file line number Diff line number Diff line change @@ -38,6 +38,24 @@ describe('The node_redis client', function () {
38
38
client . quit ( done ) ;
39
39
} ) ;
40
40
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
+
41
59
helper . allTests ( function ( parser , ip , args ) {
42
60
43
61
describe ( 'using ' + parser + ' and ' + ip , function ( ) {
You can’t perform that action at this time.
0 commit comments