Remove timeout from task submitter

This commit is contained in:
Joel Collins 2020-05-18 16:23:01 +01:00
parent 5d6f85c374
commit bc1df9542d

View file

@ -55,11 +55,6 @@ export default {
required: false, required: false,
default: 0.5 default: 0.5
}, },
pollTimeout: {
type: Number,
required: false,
default: 1800
},
submitLabel: { submitLabel: {
type: String, type: String,
required: false, required: false,
@ -138,11 +133,7 @@ export default {
this.taskRunning = true; this.taskRunning = true;
this.$emit("taskStarted", this.taskId); this.$emit("taskStarted", this.taskId);
// Return the poll-task promise (starts polling the task) // Return the poll-task promise (starts polling the task)
return this.pollTask( return this.pollTask(this.taskId, this.pollInterval);
this.taskId,
this.pollTimeout,
this.pollInterval
);
}) })
.then(response => { .then(response => {
// Do something with the final response // Do something with the final response
@ -170,8 +161,7 @@ export default {
}); });
}, },
pollTask: function(taskId, timeout, interval) { pollTask: function(taskId, interval) {
var endTime = Number(new Date()) + (timeout * 1000 || 30000);
interval = interval * 1000 || 500; interval = interval * 1000 || 500;
var checkCondition = (resolve, reject) => { var checkCondition = (resolve, reject) => {
@ -200,17 +190,13 @@ export default {
// Pass status string as error // Pass status string as error
reject(new Error(result)); reject(new Error(result));
} }
// If the condition isn't met but the timeout hasn't elapsed, go again // Didn't match and too much time, reject!
else if (Number(new Date()) < endTime) { else {
// Since the task is still running, we can update the progress bar // Since the task is still running, we can update the progress bar
this.progress = response.data.progress; this.progress = response.data.progress;
// Check again after timeout // Check again after timeout
setTimeout(checkCondition, interval, resolve, reject); setTimeout(checkCondition, interval, resolve, reject);
} }
// Didn't match and too much time, reject!
else {
reject(new Error("Polling timed out"));
}
}); });
}; };