@@ -38,9 +38,13 @@ function RedisClient(stream, options) {
3838
3939 this . pipeline = 0 ;
4040 if ( ! stream . cork ) {
41- stream . cork = function noop ( ) {
42- self . pipeline_queue = new Queue ( ) ;
43- } ;
41+ this . cork = function noop ( len ) { } ;
42+ this . once ( 'ready' , function ( ) {
43+ self . cork = function ( len ) {
44+ self . pipeline = len ;
45+ self . pipeline_queue = new Queue ( len ) ;
46+ } ;
47+ } ) ;
4448 stream . uncork = function noop ( ) { } ;
4549 this . write = this . writeStream ;
4650 }
@@ -128,6 +132,10 @@ RedisClient.prototype.install_stream_listeners = function() {
128132 } ) ;
129133} ;
130134
135+ RedisClient . prototype . cork = function ( len ) {
136+ this . stream . cork ( ) ;
137+ } ;
138+
131139RedisClient . prototype . initialize_retry_vars = function ( ) {
132140 this . retry_timer = null ;
133141 this . retry_totaltime = 0 ;
@@ -1074,8 +1082,7 @@ Multi.prototype.exec_transaction = function (callback) {
10741082 var cb ;
10751083 this . errors = [ ] ;
10761084 this . callback = callback ;
1077- this . _client . stream . cork ( ) ;
1078- this . _client . pipeline = len + 2 ;
1085+ this . _client . cork ( len + 2 ) ;
10791086 this . wants_buffers = new Array ( len ) ;
10801087 this . send_command ( 'multi' , [ ] ) ;
10811088 // drain queue, callback will catch 'QUEUED' or error
@@ -1192,8 +1199,7 @@ Multi.prototype.exec = Multi.prototype.EXEC = Multi.prototype.exec_batch = funct
11921199 return true ;
11931200 }
11941201 this . results = new Array ( len ) ;
1195- this . _client . stream . cork ( ) ;
1196- this . _client . pipeline = len ;
1202+ this . _client . cork ( len ) ;
11971203 var lastCallback = function ( cb ) {
11981204 return function ( err , res ) {
11991205 cb ( err , res ) ;
0 commit comments