You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-09 00:22:08 +03:00
Add monitor transaction warning / error
This commit is contained in:
@@ -71,14 +71,9 @@ Multi.prototype.monitor = Multi.prototype.MONITOR = function monitor (callback)
|
||||
this.queue.push(['monitor', [], monitor_callback(this._client, callback)]);
|
||||
return this;
|
||||
}
|
||||
var err = new Error(
|
||||
'You used the monitor command in combination with a transaction. Due to faulty return values of ' +
|
||||
'Redis in this context, the monitor command is now executed without transaction instead and ignored ' +
|
||||
'in the multi statement.'
|
||||
);
|
||||
err.command = 'MONITOR';
|
||||
utils.reply_in_order(this._client, callback, err);
|
||||
this._client.monitor('monitor', callback);
|
||||
// Set multi monitoring to indicate the exec that it should abort
|
||||
// Remove this "hack" as soon as Redis might fix this
|
||||
this.monitoring = true;
|
||||
return this;
|
||||
};
|
||||
|
||||
|
@@ -85,6 +85,14 @@ function multi_callback (self, err, replies) {
|
||||
}
|
||||
|
||||
Multi.prototype.exec_transaction = function exec_transaction (callback) {
|
||||
if (this.monitoring || this._client.monitoring) {
|
||||
var err = new Error(
|
||||
'Using transaction with a client that is in monitor mode does not work due to faulty return values of Redis.'
|
||||
);
|
||||
err.command = 'EXEC';
|
||||
err.code = 'EXECABORT';
|
||||
return utils.reply_in_order(this._client, callback, err);
|
||||
}
|
||||
var self = this;
|
||||
var len = self.queue.length;
|
||||
self.errors = [];
|
||||
|
Reference in New Issue
Block a user