AWS SDK ElasticTranscoder readJob returns undefined

34 views Asked by At

I'm using the AWS SDK for Javascript and, I have this code for reading a job:


const getJobOutputDuration=async()=>{
   // read jobInfo
   const jobDetailsResult = const result = await elasticTranscoder.readJob({ Id: jobId }).promise();
  // if not found, throw an error
  if (! jobDetailsResult.Job?.Id) {
      throw new Error("Job object not found!");
    }

  // read output duration from job
  const outputDuration = jobDetails.Job.Output?.Duration
  return outputDuration;
}

But sometimes, the outputDuration returns undefined. The code flow is:

  1. Trigger a job on ElasticTranscoder
  2. Save the Elastic Transcoder jobId on the database
  3. Once ElasticTranscoder finishes, it saves the output file in an S3 bucket
  4. The S3 bucket emits an event to SNS
  5. SNS sends the event to an endpoint in my code
  6. The code runs the function getJobOutputDuration previously defined

Ps: I noticed that when I try to run the same code after a few minutes, it does return the output duration correctly

0

There are 0 answers