diff --git a/dist/index.js b/dist/index.js index 7b3e0c8..5f4ccd3 100644 --- a/dist/index.js +++ b/dist/index.js @@ -7019,7 +7019,7 @@ function run() { else { const waitTimeoutSeconds = parseInt(waitTimeoutStr); runDownload = (action) => __awaiter(this, void 0, void 0, function* () { - const waitUntil = new Date().getSeconds() + waitTimeoutSeconds; + const waitUntil = Date.now() + waitTimeoutSeconds * 1000; let lastError; do { try { @@ -7027,11 +7027,13 @@ function run() { } catch (e) { lastError = e; - core.info('Waiting for the artifact to become available...'); + core.info('Waiting for the artifact to become available... ' + + `Remaining time until timeout: ${Math.max(0, Math.floor((waitUntil - Date.now()) / 1000))} seconds`); yield new Promise(f => setTimeout(f, 10000)); } - } while (new Date().getSeconds() < waitUntil); - throw Error('Timeout reached. Latest error: ' + lastError); + } while (Date.now() < waitUntil); + throw Error('Waiting for the artifact has timed out. Latest error was: ' + + lastError); }); } let resolvedPath; diff --git a/src/download-artifact.ts b/src/download-artifact.ts index a815803..9fefe8f 100644 --- a/src/download-artifact.ts +++ b/src/download-artifact.ts @@ -17,18 +17,27 @@ async function run(): Promise { } else { const waitTimeoutSeconds = parseInt(waitTimeoutStr) runDownload = async (action: () => T) => { - const waitUntil = new Date().getSeconds() + waitTimeoutSeconds + const waitUntil = Date.now() + waitTimeoutSeconds * 1000 let lastError do { try { return await action() } catch (e) { lastError = e - core.info('Waiting for the artifact to become available...') + core.info( + 'Waiting for the artifact to become available... ' + + `Remaining time until timeout: ${Math.max( + 0, + Math.floor((waitUntil - Date.now()) / 1000) + )} seconds` + ) await new Promise(f => setTimeout(f, 10000)) } - } while (new Date().getSeconds() < waitUntil) - throw Error('Timeout reached. Latest error: ' + lastError) + } while (Date.now() < waitUntil) + throw Error( + 'Waiting for the artifact has timed out. Latest error was: ' + + lastError + ) } }