File tree Expand file tree Collapse file tree 1 file changed +5
-7
lines changed
Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -490,15 +490,13 @@ RedisClient.prototype.connection_gone = function (why) {
490490 return ;
491491 }
492492
493- // Flush all commands that have not yet returned. We can't handle them appropriatly
494- if ( this . command_queue . length !== 0 ) {
493+ // Retry commands after a reconnect instead of throwing an error. Use this with caution
494+ if ( this . options . retry_unfulfilled_commands ) {
495+ this . offline_queue . unshift . apply ( this . offline_queue , this . command_queue . toArray ( ) ) ;
496+ this . command_queue . clear ( ) ;
497+ } else if ( this . command_queue . length !== 0 ) {
495498 error = new Error ( 'Redis connection lost and command aborted in uncertain state. It might have been processed.' ) ;
496499 error . code = 'UNCERTAIN_STATE' ;
497- // TODO: Evaluate to add this
498- // if (this.options.retry_commands) {
499- // this.offline_queue.unshift(this.command_queue.toArray());
500- // error.message = 'Command aborted in uncertain state and queued for next connection.';
501- // }
502500 this . flush_and_error ( error , [ 'command_queue' ] ) ;
503501 error . message = 'Redis connection lost and commands aborted in uncertain state. They might have been processed.' ;
504502 this . emit ( 'error' , error ) ;
You can’t perform that action at this time.
0 commit comments