@pager/jackrabbit
Advanced tools
Comparing version 5.4.1 to 5.4.2-a001
'use strict'; | ||
const Amqp = require('amqplib/callback_api'); | ||
const AmqpConnection = require('amqplib/lib/connection'); | ||
const Extend = require('lodash.assignin'); | ||
@@ -97,11 +98,21 @@ const EventEmitter = require('events').EventEmitter; | ||
const bail = (err) => { | ||
const bail = (err, newConnectionAttempt = false) => { | ||
// TODO close any connections or channels that remain open | ||
connection = undefined; | ||
if (err && !tryReconnect(err)) { | ||
rabbit.emit('error', err); | ||
doLog('fatal', 'Rabbit connection error!'); | ||
process.exit(1); | ||
if (!err) { | ||
return; | ||
} | ||
if (newConnectionAttempt && tryReconnect(err)) { | ||
return; | ||
} | ||
if (!newConnectionAttempt && (err.onConnectionErrorEvent || !isReconnectionError(err)) && tryReconnect(err)) { | ||
return; | ||
} | ||
rabbit.emit('error', err); | ||
doLog('fatal', 'Rabbit connection error!'); | ||
process.exit(1); | ||
}; | ||
@@ -111,3 +122,3 @@ | ||
return err.code === 320 || err.message === 'Socket closed abruptly during opening handshake' || err.message.includes('ECONNREFUSED'); | ||
return AmqpConnection.isFatalError(err); | ||
}; | ||
@@ -130,6 +141,2 @@ | ||
if (!isReconnectionError(err)) { | ||
return false; | ||
} | ||
if (connectionAttempts >= options.maxRetries) { | ||
@@ -163,3 +170,3 @@ err.meta = 'Error connecting to RabbitMQ'; | ||
if (err) { | ||
return bail(err); | ||
return bail(err, true); | ||
} | ||
@@ -170,2 +177,5 @@ | ||
connection.once('close', bail.bind(this)); | ||
connection.on('error', (err) => { | ||
err.onConnectionErrorEvent = true; | ||
}); | ||
connection.on('blocked', (cause) => rabbit.emit('blocked', cause)); | ||
@@ -172,0 +182,0 @@ connection.on('unblocked', () => rabbit.emit('unblocked')); |
{ | ||
"name": "@pager/jackrabbit", | ||
"version": "5.4.1", | ||
"version": "5.4.2-a001", | ||
"description": "Easy RabbitMQ for node", | ||
@@ -50,9 +50,9 @@ "keywords": [ | ||
"chai": "4.x", | ||
"dotenv": "16.0.0", | ||
"dotenv": "16.0.1", | ||
"eslint": "7.x", | ||
"eslint-config-hapi": "12.x", | ||
"eslint-plugin-hapi": "4.x", | ||
"mocha": "9.x", | ||
"mocha": "10.x", | ||
"semantic-release": "19.x", | ||
"sinon": "11.x" | ||
"sinon": "14.x" | ||
}, | ||
@@ -59,0 +59,0 @@ "mocha": { |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
658
26677
5
2
1