Comparing version 10.2.2 to 10.2.3
# Change Log | ||
## 10.2.3 | ||
### Fixed | ||
- Fixed second part of issue [#121](https://github.com/guidesmiths/rascal/issues/121), where the generic-pool could cause tight loops and memory leaks | ||
## 10.2.2 | ||
@@ -4,0 +8,0 @@ ### Fixed |
@@ -5,5 +5,7 @@ module.exports = { | ||
publicationChannelPools: { | ||
regularPool: { | ||
confirmPool: { | ||
max: 10, | ||
min: 5, | ||
min: 10, | ||
evictionRunIntervalMillis: 1000, | ||
idleTimeoutMillis: 5000, | ||
autostart: true | ||
@@ -10,0 +12,0 @@ } |
@@ -8,2 +8,4 @@ const Rascal = require('../..') | ||
broker.on('error', console.error); | ||
const stream = random.createRandomStream() | ||
@@ -10,0 +12,0 @@ .on('error', console.error) |
@@ -181,4 +181,13 @@ var debug = require('debug')('rascal:Vhost'); | ||
return new Promise(function(resolve, reject) { | ||
createChannel(options.confirm, function(err, channel) { | ||
if (err) return reject(err); | ||
debug('Creating pooled %s channel for vhost: %s', mode, config.name); | ||
createChannelWhenInitialised(options.confirm, function(err, channel) { | ||
if (err) { | ||
// generic-pool does not handle rejection well! | ||
// https://github.com/coopernurse/node-pool/issues/197#issuecomment-477862861 | ||
debug('Error creating pooled %s channel. %s for vhost: %s. %s', mode, config.name, err.message); | ||
setTimeoutUnref(function() { | ||
reject(err); | ||
}, options.pool.rejectionDelayMillis); | ||
return; | ||
} | ||
var destroyChannel = _.once(function() { | ||
@@ -188,3 +197,3 @@ channel._rascal_closed = true; | ||
pool.destroy(channel).catch(function(err) { | ||
debug('Error destroying %s channel: %s. %s', mode, err.message); | ||
debug('Error destroying pooled %s channel: %s for vhost: %s. %s', mode, config.name, err.message); | ||
}); | ||
@@ -298,2 +307,11 @@ } | ||
function createChannelWhenInitialised(confirm, next) { | ||
if (connection) return createChannel(confirm, next); | ||
debug('Vhost: %s is not initialised. Deferring channel creation', self.name); | ||
self.once('vhost_initialised', function() { | ||
debug('Vhost: %s was initialised. Resuming channel creation', self.name); | ||
createChannel(confirm, next); | ||
}); | ||
} | ||
function createChannel(confirm, next) { | ||
@@ -300,0 +318,0 @@ |
@@ -11,2 +11,3 @@ module.exports = { | ||
idleTimeoutMillis: 60000, | ||
rejectionDelayMillis: 1000, | ||
testOnBorrow: true, | ||
@@ -20,2 +21,3 @@ }, | ||
idleTimeoutMillis: 60000, | ||
rejectionDelayMillis: 1000, | ||
testOnBorrow: true, | ||
@@ -22,0 +24,0 @@ }, |
{ | ||
"name": "rascal", | ||
"version": "10.2.2", | ||
"version": "10.2.3", | ||
"description": "A config driven wrapper for amqplib supporting multi-host connections, automatic error recovery, redelivery flood protection, transparent encryption / decryption, channel pooling and publication timeouts", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -492,2 +492,3 @@ # Rascal | ||
``` | ||
Unfortunately there is a [bug](https://github.com/coopernurse/node-pool/issues/197#issuecomment-477862861) in generic-pool's implementation, which means that if the pool fails to create a channel, it can enter a tight loop, thrashing your CPU and potentially crashing your node process due to a memory leak. While we assess the long term use of pooling, we have put in a workaround. Errors will only be rejected after a configurable delay. This defaults to one second but can be overriden through the `rejectionDelayMillis` pool attribute. Special thanks to @willthrom for helping diagnose and fix this issue. | ||
@@ -494,0 +495,0 @@ #### Flow Control |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
484738
11728
1569