private async pollForImage()

in src/commands/image/reingest.ts [109:125]


  private async pollForImage(id: string, maxIterations = 5, delayBetweenRequestsInMs = 2000) {
    let currentIteration = 0
    process.stdout.write('Polling to check that image has been reingested successfully')
    while (currentIteration < maxIterations) {
      const imageResponse = await this.fetchImage(id)
      process.stdout.write('.')
      if (this.imageExists(imageResponse)) {
        return
      }

      await this.wait(delayBetweenRequestsInMs)
      currentIteration++
    }

    this.log('\n')
    throw new Error(`Timed out trying to find image – tried ${maxIterations} times over ${maxIterations * delayBetweenRequestsInMs / 1000} seconds`)
  }