mirror of
https://github.com/actions/download-artifact.git
synced 2025-07-23 15:08:29 +02:00
fix: timeout calculation
This commit is contained in:
parent
3682b366b0
commit
989a39a417
2 changed files with 19 additions and 8 deletions
10
dist/index.js
vendored
10
dist/index.js
vendored
|
@ -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;
|
||||
|
|
|
@ -17,18 +17,27 @@ async function run(): Promise<void> {
|
|||
} else {
|
||||
const waitTimeoutSeconds = parseInt(waitTimeoutStr)
|
||||
runDownload = async <T extends unknown>(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
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue