1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-09 00:22:08 +03:00

Fix parser incorrect buffer skip for MULTI/EXEC transaction errors with WATCH.

Signed-off-by: DTrejo <david.daniel.trejo@gmail.com>
This commit is contained in:
Bryce Baril
2013-02-23 19:20:30 -08:00
committed by DTrejo
parent 87132e2b03
commit 0c172f425c
2 changed files with 36 additions and 2 deletions

View File

@@ -117,7 +117,6 @@ ReplyParser.prototype._parseResult = function (type) {
}
if (packetHeader.size < 0) {
this._offset += 2;
return null;
}
@@ -295,4 +294,4 @@ ReplyParser.prototype.send_error = function (reply) {
ReplyParser.prototype.send_reply = function (reply) {
this.emit("reply", reply);
};
};

35
test.js
View File

@@ -454,6 +454,41 @@ tests.WATCH_MULTI = function () {
multi.exec(last(name, require_null(name)));
};
tests.WATCH_TRANSACTION = function () {
var name = "WATCH_TRANSACTION";
if (!server_version_at_least(client, [2, 1, 0])) {
console.log("Skipping " + name + " because server version isn't new enough.");
return next(name);
}
// Test WATCH command aborting transactions, look for parser offset errors.
client.set("unwatched", 200);
client.set(name, 0);
client.watch(name);
client.incr(name);
var multi = client.multi()
.incr(name)
.exec(function (err, replies) {
// Failure expected because of pre-multi incr
assert.strictEqual(replies, null, "Aborted transaction multi-bulk reply should be null.");
client.get("unwatched", function (err, reply) {
assert.equal(err, null, name);
assert.equal(reply, 200, "Expected 200, got " + reply);
next(name);
});
});
client.set("unrelated", 100, function (err, reply) {
assert.equal(err, null, name);
assert.equal(reply, "OK", "Expected 'OK', got " + reply);
});
};
tests.detect_buffers = function () {
var name = "detect_buffers", detect_client = redis.createClient(null, null, {detect_buffers: true});