rabbot
rabbot copied to clipboard
Second call of addConnection when retrying connection doesn't update connectionPromise
Version: 2.1.0 release. Symptom: Even after I saw the rabbot made a connection after the first failure, publish or request is always rejected with error of 'no endpoint could not be reached'.
Details:
I sometimes get the first ETIMEDOUT error when call addConnection
, but rabbot reconnects and gets the connection successfully. I can check the established connection by setup the event handler on 'connected' event.
But when I try to send any request to an exchange, I get 'No endpoint could not be reached' error, and rabbot.request
or rabbot.publish
is rejected immediately. After I digging into code little bit, I found that it is because connectionPromise
is not be replaced (or resolved) after the second connection trial succeeded. connectionPromise
is set as rejected because the first connection trial ends with error, and publish or request operation on rabbot always refer first connectionPromise
. (see onExchange
function of src/index.js
)
Relevant code position is, src/index.js
's 129th line. Inside the second call of addConnection
, connectionPromise
is newly created, but if (!this.connections[ name ].promise) {
this line doesn't allow connection promise being updated.
FYI: that line is introduced in https://github.com/arobson/rabbot/commit/4bfd3527d9a4657afc85c504c5c4460516195c4b
Good job finding the line!
Related issue is discussed here https://github.com/arobson/rabbot/issues/108.