Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improved timeout handling #404

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading