Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ioredis

Package Overview
Dependencies
Maintainers
1
Versions
228
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ioredis - npm Package Compare versions

Comparing version 1.3.4 to 1.3.5

5

Changelog.md

@@ -5,2 +5,7 @@ ## Changelog

### v1.3.5 - May 21, 2015
* Fix possible memory leak warning of Cluster.
* Stop reconnecting when disconnected manually.
### v1.3.4 - May 21, 2015

@@ -7,0 +12,0 @@

13

lib/cluster.js

@@ -74,3 +74,3 @@ 'use strict';

var refreshListener = function () {
this.removeListener('end', endListener);
this.removeListener('close', closeListener);
this.retryAttempts = 0;

@@ -84,3 +84,3 @@ this.manuallyClosing = false;

var endListener = function () {
var closeListener = function () {
this.removeListener('refresh', refreshListener);

@@ -91,3 +91,3 @@ reject(new Error('None of startup nodes is available'));

this.once('refresh', refreshListener);
this.once('end', endListener);
this.once('close', closeListener);

@@ -101,3 +101,4 @@ this.once('close', function () {

this.setStatus('reconnecting');
setTimeout(function () {
this.reconnectTimeout = setTimeout(function () {
this.reconnectTimeout = null;
debug('Cluster is disconnected. Retrying after %dms', retryDelay);

@@ -128,2 +129,6 @@ this.connect().catch(function () {});

}
if (this.reconnectTimeout) {
clearTimeout(this.reconnectTimeout);
this.reconnectTimeout = null;
}
var keys = Object.keys(this.nodes);

@@ -130,0 +135,0 @@ for (var i = 0; i < keys.length; ++i) {

@@ -278,2 +278,6 @@ 'use strict';

}
if (this.reconnectTimeout) {
clearTimeout(this.reconnectTimeout);
this.reconnectTimeout = null;
}
this.connector.disconnect();

@@ -280,0 +284,0 @@ };

@@ -72,3 +72,4 @@ 'use strict';

self.setStatus('reconnecting', retryDelay);
setTimeout(function () {
self.reconnectTimeout = setTimeout(function () {
self.reconnectTimeout = null;
self.connect().catch(function () {});

@@ -75,0 +76,0 @@ }, retryDelay);

{
"name": "ioredis",
"version": "1.3.4",
"version": "1.3.5",
"description": "A delightful, performance-focused Redis client for Node and io.js",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -54,15 +54,76 @@ 'use strict';

it('should discover other nodes automatically', function (done) {
var node1 = new MockServer(30001, function (argv) {
it('should return a promise to be resolved when connected', function (done) {
var slotTable = [
[0, 5460, ['127.0.0.1', 30001]],
[5461, 10922, ['127.0.0.1', 30002]],
[10923, 16383, ['127.0.0.1', 30003]]
];
var argvHandler = function (argv) {
if (argv[0] === 'cluster' && argv[1] === 'slots') {
return [
[0, 5460, ['127.0.0.1', 30001]],
[5461, 10922, ['127.0.0.1', 30002]],
[10923, 16383, ['127.0.0.1', 30003]]
];
return slotTable;
}
};
var node1 = new MockServer(30001, argvHandler);
var node2 = new MockServer(30002, argvHandler);
var node3 = new MockServer(30003, argvHandler);
stub(Redis.Cluster.prototype, 'connect', function () {
return Promise.resolve();
});
var node2 = new MockServer(30002);
var node3 = new MockServer(30003);
var cluster = new Redis.Cluster([
{ host: '127.0.0.1', port: '30001' }
], { lazyConnect: false });
Redis.Cluster.prototype.connect.restore();
cluster.connect().then(function () {
cluster.disconnect();
disconnect([node1, node2, node3], done);
});
});
it('should return a promise to be rejected when closed', function (done) {
stub(Redis.Cluster.prototype, 'connect', function () {
return Promise.resolve();
});
var cluster = new Redis.Cluster([
{ host: '127.0.0.1', port: '30001' }
], { lazyConnect: false });
Redis.Cluster.prototype.connect.restore();
cluster.connect().catch(function () {
cluster.disconnect();
done();
});
});
it('should stop reconnecting when disconnected', function (done) {
var cluster = new Redis.Cluster([
{ host: '127.0.0.1', port: '30001' }
], { clusterRetryStrategy: function () { return 0; } });
cluster.on('close', function () {
cluster.disconnect();
stub(Redis.Cluster.prototype, 'connect').throws(new Error('`connect` should not be called'));
setTimeout(function () {
Redis.Cluster.prototype.connect.restore();
done();
}, 1);
});
});
it('should discover other nodes automatically', function (done) {
var slotTable = [
[0, 5460, ['127.0.0.1', 30001]],
[5461, 10922, ['127.0.0.1', 30002]],
[10923, 16383, ['127.0.0.1', 30003]]
];
var argvHandler = function (argv) {
if (argv[0] === 'cluster' && argv[1] === 'slots') {
return slotTable;
}
};
var node1 = new MockServer(30001, argvHandler);
var node2 = new MockServer(30002, argvHandler);
var node3 = new MockServer(30003, argvHandler);
var pending = 3;

@@ -69,0 +130,0 @@ node1.once('connect', check);

@@ -87,2 +87,17 @@ 'use strict';

});
it('should stop reconnecting when disconnected', function (done) {
var redis = new Redis(8999, {
retryStrategy: function () { return 0; }
});
redis.on('close', function () {
redis.disconnect();
stub(Redis.prototype, 'connect').throws(new Error('`connect` should not be called'));
setTimeout(function () {
Redis.prototype.connect.restore();
done();
}, 1);
});
});
});

@@ -89,0 +104,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc