New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

rethinkdbdash

Package Overview
Dependencies
Maintainers
1
Versions
153
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rethinkdbdash - npm Package Compare versions

Comparing version 1.13.4 to 1.13.5

56

lib/pool.js

@@ -18,2 +18,3 @@ var Promise = require('bluebird');

this.options.timeoutGb = options.timeoutGb || 60*60*1000; // Default timeout for TCP connection is 2 hours on Linux, we time out after one hour.
this.options.maxExponent = options.maxExponent || 12; // Maximum timeout is 2^maxExponent*timeoutError

@@ -34,2 +35,6 @@ this.options.connection = {

this._numConnections = 0;
this._openingConnections = 0; // Number of connections being opened
this._consecutiveFails = 0; // In slow growth, the number of consecutive failures to open a connection
this._slowGrowth = false; // Opening one connection at a time
this._slowlyGrowing = false; // The next connection to be returned is one opened in slowGrowth mode

@@ -54,3 +59,5 @@ for(var i=0; i<this.options.min; i++) {

self._expandBuffer();
if (self._slowGrowth === false) {
self._expandBuffer();
}

@@ -103,3 +110,25 @@ });

self._numConnections++;
self._openingConnections++;
self._r.connect(self.options.connection).then(function(connection) {
self._openingConnections--;
if ((self._slowlyGrowing === false) && (self._slowGrowth === true) && (self._openingConnections === 0)) {
self._consecutiveFails++;
self._slowlyGrowing = true;
setTimeout(function() {
self.createConnection();
//self._expandBuffer();
}, (1<<Math.max(self.options.maxExponent, self._consecutiveFails))*self.options.timeoutError);
}
// Need another flag
else if ((self._slowlyGrowing === true) && (self._slowGrowth === true) && (self._consecutiveFails > 0)) {
console.log("Exiting slow growth mode");
self._consecutiveFails = 0;
self._slowGrowth = false;
self._slowlyGrowing = false;
self._aggressivelyExpandBuffer();
}
connection.on('error', function(e) {

@@ -157,2 +186,11 @@ // We are going to close connection, but we don't want another process to use it before

}).error(function(error) {
// We failed to create a connection, we are now going to create connections one by one
self._openingConnections--;
self._numConnections--;
self._slowGrowth = true;
if (self._slowlyGrowing === false) {
console.log("Entering slow growth mode");
}
self._slowlyGrowing = true;
// Log an error

@@ -162,8 +200,18 @@ console.log("Fail to create a new connection for the connection pool The error returned was:")

console.log(error.stack);
setTimeout(function() {
self._expandBuffer();
}, self.options.timeoutError);
if (self._openingConnections === 0) {
self._consecutiveFails++;
setTimeout(function() {
//self._expandBuffer();
self.createConnection();
}, (1<<Math.max(self.options.maxExponent, self._consecutiveFails))*self.options.timeoutError);
}
})
};
Pool.prototype._aggressivelyExpandBuffer = function() {
for(var i=0; i<this._line.getLength(); i++) {
this._expandBuffer();
}
}
Pool.prototype._expandBuffer = function() {

@@ -170,0 +218,0 @@ if ((this._draining === null) && (this._pool.getLength() < this.options.bufferSize) && (this._numConnections < this.options.max)) {

2

package.json
{
"name": "rethinkdbdash",
"version": "1.13.4",
"version": "1.13.5",
"description": "A Node.js driver for RethinkDB with promises and a connection pool",

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

@@ -93,2 +93,3 @@ rethinkdbdash

timeoutGb: <number>, // how long the pool keep a connection that hasn't been used (in ms), default 60*60*1000
maxExponent: <number> // the maximum timeout before trying to reconnect is 2^maxExponent*timeoutError
}

@@ -157,2 +158,3 @@ ```

timeoutGb: <number>, // how long the pool keep a connection that hasn't been used (in ms), default 60*60*1000
maxExponent: <number> // the maximum timeout before trying to reconnect is 2^maxExponent*timeoutError
});

@@ -159,0 +161,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