asterisk / node-ari-client

Node.js client for ARI. This library is best effort with limited support.
Other
250 stars 98 forks source link

Fix error being swallowed up #80

Closed glyphCezilleSantillan closed 7 years ago

glyphCezilleSantillan commented 7 years ago

Also for #76 . The mysteriously vanishing error was being swallowed up by this code:

reject = _.once((function (oldReject) {
    return function () {
      oldReject();
      resolve = function () {};
    };
})(reject));

All it needed was the error parameter:

reject = _.once((function (oldReject) {
    return function(err) {
        oldReject(err);
        ...

However, Underscore's _.once handles this for us already, so I just changed it to

 reject = _.once(reject);
glyphCezilleSantillan commented 7 years ago

However, the initial code also did the same thing -- the resolve and reject were called only once, and actually overwritten with noop. Calling once did the same thing, only shorter. Perhaps the entire code block could be removed, since, like you said, promises get resolved/rejected only once?

danjenkins commented 7 years ago

What do you think @chadxz / @samuelg ? From what I understand, this is the right course of action

samuelg commented 7 years ago

Published v1.1.1 to npm.

danjenkins commented 7 years ago

thanks @samuelg ! I was walking the dog when @chadxz approved otherwise I would have released the changes :)