mranney/node_redis — Issue #158: EXEC callback does not pass an error if transaction fails
Author: dickhardt
Created: 2011-11-30 22:08:55+00:00
State: open

When telnet into Redis, EXEC returns "*-1" if the transaction fails, but node_redis does not pass the error back in the callback. (perhaps it should not be?) See attached script to replicate.

I tried to figure out how to fix it, but my JS skills are not up to the task yet.

var redis = require("redis");
var async = require("async");

client1 = redis.createClient();
client2 = redis.createClient();

multi1 = client1.multi();
multi2 = client2.multi();

async.series([
function(callback){
client1.flushdb(callback);
},
function(callback){
client1.watch('a1',callback);
},
function(callback){
client2.watch('a1',callback);
},
function(callback){
multi1.set('a1','b1');
multi2.set('a1','b2');
callback();
},
function(callback){
multi1.exec(function(err,result) {
console.log('multi1 returned err:'+err+' result:'+result);
callback();
});
},
function(callback){
multi2.exec(function(err,result) {
console.log('multi2 returned err:'+err+' result:'+result);
callback();
});
}
]);

OUPUT

multi1 returned err:null result:OK
multi2 returned err:null result:null