Comparing version 1.0.1 to 1.0.2
@@ -24,3 +24,3 @@ "use strict"; | ||
var connect = (function connectWrapper() { | ||
var connectionPromise, connection, isConnected = false; | ||
var connectionPromise, connection, isConnected = false, connectOpts = {}; | ||
@@ -45,2 +45,12 @@ function ready() { | ||
connectionError(new Error("Connection closed prematurely, please check your credentials")); | ||
} else if (connectOpts.reconnect){ | ||
// monkey patch b/c node-amqp seems to be not maintained anymore based | ||
// upon number of open issues, comments within issues stating it is no | ||
// longer maintained and the age of open pull requests. node-amqp only | ||
// publishes an error on the "end" event if the "ready" event has not | ||
// yet been fired which means you probably have an issue authing with | ||
// Rabbit. They should also have an else block and look to see if the | ||
// socket is destroyed and if so, emit an error to which node-amqp | ||
// will attempt to reconnect using the specified strategy. | ||
connection.emit("error", new Error("Connection closed, attempting to reconnect")); | ||
} | ||
@@ -51,2 +61,3 @@ } | ||
if (!connectionPromise) { | ||
connectOpts = opts; | ||
connectionPromise = new Promise(); | ||
@@ -56,3 +67,5 @@ connection = amqp.createConnection(url, opts); | ||
connection.once('error', connectionError); | ||
connection.once("close", checkConnected); | ||
// use on instead of once for `close` so we can handle multiple | ||
// subsequent disconnects. | ||
connection.on("close", checkConnected); | ||
} | ||
@@ -157,3 +170,4 @@ return connectionPromise; | ||
OPTIONS: ["defaultExchangeName", "reconnect", "reconnectBackoffStrategy", | ||
"reconnectExponentialLimit", "reconnectExponentialLimit", "reconnectBackoffTime"] | ||
"reconnectExponentialLimit", "reconnectExponentialLimit", "reconnectBackoffTime", | ||
"heartbeatForceReconnect"] | ||
} | ||
@@ -160,0 +174,0 @@ |
{ | ||
"name": "hare", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Wrapper around amqp to make common patterns easier", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
46625
983
1