Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function checkExecution(arn, url, timestamp, esClient) {
let error = {
Error: 'Unknown',
Cause: 'The error cause could not be determined'
};
const r = await StepFunction.getExecution(arn, true);
r.status = r.status.toLowerCase();
r.status = r.status === 'succeeded' ? 'completed' : r.status;
if (r.status === 'not_found') {
log.error(`Execution does not exist: ${arn}`);
error = {
Error: 'Not Found',
Cause: 'Execution was not found. If an execution is '
+ 'finished and the state machine is deleted, this error is thrown'
};
await partialRecordUpdate(esClient, arn, 'execution', { status: 'failed', error });
await updateGranulesAndPdrs(esClient, url, error);
return;
}