github icon indicating copy to clipboard operation
github copied to clipboard

Please ensure there is one callback returned per function call

Open t3kkenz opened this issue 7 years ago • 0 comments

Description Many of the function calls like listRepos are returning two callbacks and is messing up my application workflow. Thanks for your time!

I found the exact location in Requestable.js:

key: '_requestAllPages',
      value: function _requestAllPages(path, options, cb, results) {
         var _this2 = this;

         results = results || [];

         return this._request('GET', path, options).then(function (response) {
            var _results;

            var thisGroup = void 0;
            if (response.data instanceof Array) {
               thisGroup = response.data;
            } else if (response.data.items instanceof Array) {
               thisGroup = response.data.items;
            } else {
               var message = 'cannot figure out how to append ' + response.data + ' to the result set';
               throw new ResponseError(message, path, response);
            }
            (_results = results).push.apply(_results, _toConsumableArray(thisGroup));

            var nextUrl = getNextPage(response.headers.link);
            if (nextUrl) {
               log('getting next page: ' + nextUrl);
               return _this2._requestAllPages(nextUrl, options, cb, results);
            }

            if (cb) {
               cb(null, results, response);
            }

            response.data = results;
            return response;
         }).catch(callbackErrorOrThrow(cb, path));

The cb(null, results, response) is providing me with all the repos, but then the callback for the ErrorOrThrow is spawning a second callback.

t3kkenz avatar Feb 05 '19 18:02 t3kkenz