Skip to content

Commit

Permalink
Feature/audit request extend timeout (#4231)
Browse files Browse the repository at this point in the history
* IRONN-86 extend timeout for audit request

* fix comment

* fix based on feedback

* fix comment

* fix comment

* remove redundant variable

Co-authored-by: Amy Chen <[email protected]>
  • Loading branch information
achen2401 and Amy Chen authored Aug 16, 2022
1 parent 0fadb5d commit 4e656a1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions portal/static/js/src/modules/TnthAjax.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export default { /*global $ */
},
"sendRequest": function(url, method, userId, params, callback) {
if (!url) { return false; }
var REQUEST_TIMEOUT_INTERVAL = 5000;
var defaultParams = {type: method ? method : "GET", url: url, attempts: 0, max_attempts: MAX_ATTEMPTS, contentType: "application/json; charset=utf-8", dataType: "json", sync: false, timeout: 5000, data: null, useWorker: false, async: true};
var REQUEST_TIMEOUT_INTERVAL = 5000; // default timed out at 5 seconds
var defaultParams = {type: method ? method : "GET", url: url, attempts: 0, max_attempts: MAX_ATTEMPTS, contentType: "application/json; charset=utf-8", dataType: "json", sync: false, timeout: REQUEST_TIMEOUT_INTERVAL, data: null, useWorker: false, async: true};
params = params || defaultParams;
params = $.extend({}, defaultParams, params);
params.timeout = params.timeout || REQUEST_TIMEOUT_INTERVAL;
Expand Down Expand Up @@ -75,8 +75,8 @@ export default { /*global $ */
}).fail(function(xhr) {
if (params.attempts < params.max_attempts) {
(function(self, url, method, userId, params, callback) {
setTimeout(function() {
self.sendRequest(url, method, userId, params, callback);
setTimeout(function () {
self.sendRequest(url, method, userId, params, callback);
}, REQUEST_TIMEOUT_INTERVAL); //retry after 5 seconds
})(self, url, method, userId, params, callback);
} else {
Expand Down
3 changes: 2 additions & 1 deletion portal/static/js/src/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2994,7 +2994,8 @@ export default (function() {
var self = this, errorMessage = "";
$("#profileAuditLogTable").html(Utility.getLoaderHTML());
$("#profileAuditLogTable .loading-message-indicator").show();
this.modules.tnthAjax.auditLog(this.subjectId, {useWorker:true}, function(data) {
// set request times out at 5 minutes
this.modules.tnthAjax.auditLog(this.subjectId, {useWorker:true, timeout: 5 * 60 * 1000}, function(data) {
if (data.error) {
errorMessage = i18next.t("Error retrieving data from server");
}
Expand Down

0 comments on commit 4e656a1

Please sign in to comment.