Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
// These are terminal states for a job so if we're not explicitly
// watching for these then we need to stop waiting as the job
// status won't change further.
if (terminal[result]) {
throw new TSError(
`Execution cannot reach the target status, "${target}", because it is in the terminal state, "${result}"`,
{ context: { lastStatus: result } }
);
}
const elapsed = Date.now() - startTime;
if (timeoutMs > 0 && elapsed >= timeoutMs) {
throw new TSError(
`Execution status failed to change from status "${result}" to "${target}" within ${toHumanTime(timeoutMs)}`,
{ context: { lastStatus: result } }
);
}
await pDelay(intervalMs);
return checkStatus();
};
}
// These are terminal states for a job so if we're not explicitly
// watching for these then we need to stop waiting as the job
// status won't change further.
if (terminal[result]) {
throw new TSError(
`Job cannot reach the target status, "${target}", because it is in the terminal state, "${result}"`,
{ context: { lastStatus: result } }
);
}
const elapsed = Date.now() - startTime;
if (timeoutMs > 0 && elapsed >= timeoutMs) {
throw new TSError(
`Job status failed to change from status "${result}" to "${target}" within ${toHumanTime(timeoutMs)}`,
{ context: { lastStatus: result } }
);
}
await pDelay(intervalMs);
return checkStatus();
};