Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.setReferer(incomingRestOp.getUri().href);
const retryFunc = () => this.restRequestSender.sendGet(restOperation)
.then((response) => {
const body = response.getBody();
if (body.status === 'FAILED' || body.status === 'FINISHED') {
return Promise.resolve(body);
}
return Promise.reject();
})
.catch(() => Promise.reject());
// retry interval:
// - this.retryInterval for testing
// - we want to poll for more than 30 minutes because that is the TCW -> DO timeout so DO should be longer
return cloudUtil.tryUntil(
this,
{ retryIntervalMs: this.retryInterval || 5000, maxRetries: 384 },
retryFunc
)
.then((response) => {
switch (response.status) {
case 'FINISHED':
this.state.doState.updateResult(taskId, 200, STATUS.STATUS_OK, 'success');
break;
case 'FAILED':
this.state.doState.updateResult(
taskId,
422,
STATUS.STATUS_ERROR,
'failed',
response.errorMessage
return new Promise((resolve, reject) => {
const retryOptions = {};
Object.assign(retryOptions, cloudUtil.QUICK_BUT_LONG_RETRY);
retryOptions.continueOnError = true;
cloudUtil.tryUntil(this, retryOptions, retryFunc)
.then(() => {
resolve();
})
.catch((err) => {
logger.warning(`Error saving state: ${err}`);
reject(err);
});
});
}