Skip to content
This repository was archived by the owner on Jun 6, 2023. It is now read-only.

Commit ee41cca

Browse files
committed
fix for waiting on job to transition to running when it has already stopped
1 parent dfcde21 commit ee41cca

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lib/jobs/waitfor.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,13 @@ function waitfor(params, cb) {
7272
return cb(new Error('state must be either Pending, Running, Stopped, Failed, or Error'));
7373
}
7474
return method(waitfor, params, function _cb(err, job) {
75-
if (err) {
76-
return cb(err);
77-
}
78-
if (job && (job.state === targetState || job.state === 'Error'
79-
|| (job.state === 'Stopped' && params.state === 'Failed')
80-
|| (job.state === 'Failed' && params.state === 'Stopped'))) {
75+
if (err) return cb(err);
76+
if (!job) return cb(new Error('Job not found'));
77+
if (job.state === targetState ||
78+
(job.state === 'Running' && params.state === 'Pending') ||
79+
job.state === 'Error' ||
80+
job.state === 'Stopped' ||
81+
job.state === 'Failed') {
8182
return cb(null, job);
8283
}
8384
var interval = setTimeout(function _interval() {

0 commit comments

Comments
 (0)