Skip to content

Commit

Permalink
improved timeout handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Iulian Masar committed Apr 16, 2024
1 parent fa20851 commit 00fb5cc
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,19 +205,24 @@ Api.prototype = {
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
.catch(function (error) {
// if (error.code === "ERR_CANCELED" && abortSignal.aborted) {
// self.errorHandler(error.code, "Request timed out");
// }
if (error.code === "ERR_CANCELED" && abortSignal.aborted) {
var err = {
Message: "Request timed out",
Code: 408
};
self.errorHandler(err.Message, err);
reject(err);
} else {
var resolveArgument = (resolveWithFullResponse) ?
_.extend(error.response, {body: error.response.data}) : error.response.data;

var resolveArgument = (resolveWithFullResponse) ?
_.extend(error.response, {body: error.response.data}) : error.response.data;
if (_.isFunction(callback)) {
callback(resolveArgument, error.response);
}

if (_.isFunction(callback)) {
callback(resolveArgument, error.response);
self.errorHandler(error.message, error.response.data);
reject(resolveArgument);
}

self.errorHandler(error.message, error.response.data);
reject(resolveArgument);
});
});
},
Expand Down

0 comments on commit 00fb5cc

Please sign in to comment.