throw error immediately when waiting for job instead of after making api requests
Signed-off-by: Travis Glenn Hansen <travisghansen@yahoo.com>
This commit is contained in:
parent
339e952d1c
commit
b8b1188a14
|
|
@ -698,15 +698,16 @@ class Api {
|
||||||
|
|
||||||
// wait for job to finish
|
// wait for job to finish
|
||||||
do {
|
do {
|
||||||
|
currentTime = Date.now() / 1000;
|
||||||
|
if (timeout > 0 && currentTime > startTime + timeout) {
|
||||||
|
throw new Error("timeout waiting for job to complete");
|
||||||
|
}
|
||||||
|
|
||||||
if (job) {
|
if (job) {
|
||||||
await sleep(check_interval);
|
await sleep(check_interval);
|
||||||
}
|
}
|
||||||
job = await this.CoreGetJobs({ id: job_id });
|
job = await this.CoreGetJobs({ id: job_id });
|
||||||
job = job[0];
|
job = job[0];
|
||||||
currentTime = Date.now() / 1000;
|
|
||||||
if (timeout > 0 && currentTime > startTime + timeout) {
|
|
||||||
throw new Error("timeout waiting for job to complete");
|
|
||||||
}
|
|
||||||
} while (!["SUCCESS", "ABORTED", "FAILED"].includes(job.state));
|
} while (!["SUCCESS", "ABORTED", "FAILED"].includes(job.state));
|
||||||
|
|
||||||
return job;
|
return job;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue