Skip to content

Commit

Permalink
refact: log time in seconds
Browse files Browse the repository at this point in the history
This improves the readability.
  • Loading branch information
wdzeng committed Oct 3, 2024
1 parent 973c489 commit 92a6948
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import {
} from '@/error'
import { logger } from '@/utils'

const WAIT_DELAY = 10 * 1000 // 10 seconds
const MAX_WAIT_TIME = 10 * 60 * 1000 // 10 minutes
const WAIT_DELAY = 10 // 10 seconds
const MAX_WAIT_TIME = 10 * 60 // 10 minutes

async function sendUploadPackageRequest(
productId: string,
Expand Down Expand Up @@ -58,7 +58,7 @@ async function waitUntilPackageValidated(
const url = `https://api.addons.microsoftedge.microsoft.com/v1/products/${productId}/submissions/operations/${operationId}`
const headers = { 'Authorization': `ApiKey ${apiKey}`, 'X-ClientID': clientId }

const endTime = Date.now() + MAX_WAIT_TIME
const endTime = Date.now() + MAX_WAIT_TIME * 1000
logger.error(`end time is ${endTime}`)
let response: UploadStatusResponse | undefined = undefined
while (Date.now() < endTime) {
Expand All @@ -70,8 +70,8 @@ async function waitUntilPackageValidated(
break
}

logger.info(`Operation still in progress. Try again after ${WAIT_DELAY} ms.`)
await new Promise(res => setTimeout(res, WAIT_DELAY))
logger.info(`Operation still in progress. Try again after ${WAIT_DELAY} seconds.`)
await new Promise(res => setTimeout(res, WAIT_DELAY * 1000))
}

// Try for the last time.
Expand Down Expand Up @@ -152,7 +152,7 @@ async function waitUntilPackagePublished(
const url = `https://api.addons.microsoftedge.microsoft.com/v1/products/${productId}/submissions/operations/${operationId}`
const headers = { 'Authorization': `ApiKey ${apiKey}`, 'X-ClientID': clientId }

const endTime = Date.now() + MAX_WAIT_TIME
const endTime = Date.now() + MAX_WAIT_TIME * 1000
let response: PublishStatusResponse | undefined = undefined
while (Date.now() < endTime) {
logger.info('Checking if the publishing operation has succeeded.')
Expand All @@ -164,8 +164,8 @@ async function waitUntilPackagePublished(
break
}

logger.info(`Operation still in progress. Try again after ${WAIT_DELAY} ms.`)
await new Promise(res => setTimeout(res, WAIT_DELAY))
logger.info(`Operation still in progress. Try again after ${WAIT_DELAY} seconds.`)
await new Promise(res => setTimeout(res, WAIT_DELAY * 1000))
}

// Try for the last time.
Expand Down

0 comments on commit 92a6948

Please sign in to comment.