You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
Add retry_unfullfilled_commands option
This commit is contained in:
12
index.js
12
index.js
@@ -490,15 +490,13 @@ RedisClient.prototype.connection_gone = function (why) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flush all commands that have not yet returned. We can't handle them appropriatly
|
// Retry commands after a reconnect instead of throwing an error. Use this with caution
|
||||||
if (this.command_queue.length !== 0) {
|
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 = new Error('Redis connection lost and command aborted in uncertain state. It might have been processed.');
|
||||||
error.code = 'UNCERTAIN_STATE';
|
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']);
|
this.flush_and_error(error, ['command_queue']);
|
||||||
error.message = 'Redis connection lost and commands aborted in uncertain state. They might have been processed.';
|
error.message = 'Redis connection lost and commands aborted in uncertain state. They might have been processed.';
|
||||||
this.emit('error', error);
|
this.emit('error', error);
|
||||||
|
Reference in New Issue
Block a user