You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-04 15:02:09 +03:00
Calling quit should always close the connection
This commit is contained in:
@@ -68,6 +68,30 @@ RedisClient.prototype.monitor = RedisClient.prototype.MONITOR = function (callba
|
||||
});
|
||||
};
|
||||
|
||||
RedisClient.prototype.quit = RedisClient.prototype.QUIT = function (callback) {
|
||||
var self = this;
|
||||
var callback_hook = function (err, res) {
|
||||
// TODO: Improve this by handling everything with coherend error codes and find out if there's anything missing
|
||||
if (err && (err.code === 'NR_OFFLINE' ||
|
||||
err.message === 'Redis connection gone from close event.' ||
|
||||
err.message === 'The command can\'t be processed. The connection has already been closed.'
|
||||
)) {
|
||||
// Pretent the quit command worked properly in this case.
|
||||
// Either the quit landed in the offline queue and was flushed at the reconnect
|
||||
// or the offline queue is deactivated and the command was rejected right away
|
||||
// or the stream is not writable
|
||||
// or while sending the quit, the connection dropped
|
||||
err = null;
|
||||
res = 'OK';
|
||||
}
|
||||
utils.callback_or_emit(self, callback, err, res);
|
||||
};
|
||||
var backpressure_indicator = this.send_command('quit', [], callback_hook);
|
||||
// Calling quit should always end the connection, no matter if there's a connection or not
|
||||
this.closing = true;
|
||||
return backpressure_indicator;
|
||||
};
|
||||
|
||||
// Store info in this.server_info after each call
|
||||
RedisClient.prototype.info = RedisClient.prototype.INFO = function info (section, callback) {
|
||||
var self = this;
|
||||
|
Reference in New Issue
Block a user