Skip to content

Commit 606e24f

Browse files
committed
fix: update order of block method
1 parent 1f4fa16 commit 606e24f

File tree

1 file changed

+25
-21
lines changed

1 file changed

+25
-21
lines changed

src/modzy-client.js

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -283,27 +283,31 @@ class ModzyClient {
283283
*/
284284
blockUntilComplete(job) {
285285
logger.debug(`blockUntilComplete(${job.jobIdentifier}}) :: ${job.status}`);
286-
return this.jobClient.getJob(job.jobIdentifier)
287-
.then(
288-
(updatedJob) => {
289-
if (updatedJob.status === "SUBMITTED" || updatedJob.status === "IN_PROGRESS") {
290-
return new Promise(
291-
(resolve, reject) => {
292-
setTimeout(
293-
() => {
294-
resolve(
295-
this.blockUntilComplete(updatedJob)
296-
);
297-
},
298-
20000
299-
);
300-
}
301-
);
302-
}
303-
logger.debug(`blockUntilComplete(${updatedJob.jobIdentifier}}) :: returning :: ${updatedJob.status}`);
304-
return updatedJob;
305-
}
306-
)
286+
return new Promise(
287+
(resolve, reject) => {
288+
setTimeout(
289+
() => {
290+
this.jobClient.getJob(job.jobIdentifier)
291+
.then(
292+
(updatedJob) => {
293+
if (updatedJob.status === "SUBMITTED" || updatedJob.status === "IN_PROGRESS") {
294+
resolve(this.blockUntilComplete(updatedJob));
295+
}
296+
logger.debug(`blockUntilComplete(${updatedJob.jobIdentifier}}) :: returning :: ${updatedJob.status}`);
297+
resolve(updatedJob);
298+
}
299+
)
300+
.catch(
301+
(error) => {
302+
logger.error(error);
303+
reject(error);
304+
}
305+
);
306+
},
307+
2000
308+
);
309+
}
310+
);
307311
}
308312

309313
/**

0 commit comments

Comments
 (0)