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

Add retry_unfullfilled_commands option

This commit is contained in:
Ruben Bridgewater
2015-12-30 16:12:52 +01:00
parent a4285c156c
commit d9c815dd8c

View File

@@ -490,15 +490,13 @@ RedisClient.prototype.connection_gone = function (why) {
return;
}
// Flush all commands that have not yet returned. We can't handle them appropriatly
if (this.command_queue.length !== 0) {
// Retry commands after a reconnect instead of throwing an error. Use this with caution
if (this.options.retry_unfulfilled_commands) {
this.offline_queue.unshift.apply(this.offline_queue, this.command_queue.toArray());
this.command_queue.clear();
} else if (this.command_queue.length !== 0) {
error = new Error('Redis connection lost and command aborted in uncertain state. It might have been processed.');
error.code = 'UNCERTAIN_STATE';
// TODO: Evaluate to add this
// if (this.options.retry_commands) {
// this.offline_queue.unshift(this.command_queue.toArray());
// error.message = 'Command aborted in uncertain state and queued for next connection.';
// }
this.flush_and_error(error, ['command_queue']);
error.message = 'Redis connection lost and commands aborted in uncertain state. They might have been processed.';
this.emit('error', error);