mirror of
https://github.com/actions/download-artifact.git
synced 2025-07-24 23:48: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 {
|
else {
|
||||||
const waitTimeoutSeconds = parseInt(waitTimeoutStr);
|
const waitTimeoutSeconds = parseInt(waitTimeoutStr);
|
||||||
runDownload = (action) => __awaiter(this, void 0, void 0, function* () {
|
runDownload = (action) => __awaiter(this, void 0, void 0, function* () {
|
||||||
const waitUntil = new Date().getSeconds() + waitTimeoutSeconds;
|
const waitUntil = Date.now() + waitTimeoutSeconds * 1000;
|
||||||
let lastError;
|
let lastError;
|
||||||
do {
|
do {
|
||||||
try {
|
try {
|
||||||
|
@ -7027,11 +7027,13 @@ function run() {
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
lastError = 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));
|
yield new Promise(f => setTimeout(f, 10000));
|
||||||
}
|
}
|
||||||
} while (new Date().getSeconds() < waitUntil);
|
} while (Date.now() < waitUntil);
|
||||||
throw Error('Timeout reached. Latest error: ' + lastError);
|
throw Error('Waiting for the artifact has timed out. Latest error was: ' +
|
||||||
|
lastError);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
let resolvedPath;
|
let resolvedPath;
|
||||||
|
|
|
@ -17,18 +17,27 @@ async function run(): Promise<void> {
|
||||||
} else {
|
} else {
|
||||||
const waitTimeoutSeconds = parseInt(waitTimeoutStr)
|
const waitTimeoutSeconds = parseInt(waitTimeoutStr)
|
||||||
runDownload = async <T extends unknown>(action: () => T) => {
|
runDownload = async <T extends unknown>(action: () => T) => {
|
||||||
const waitUntil = new Date().getSeconds() + waitTimeoutSeconds
|
const waitUntil = Date.now() + waitTimeoutSeconds * 1000
|
||||||
let lastError
|
let lastError
|
||||||
do {
|
do {
|
||||||
try {
|
try {
|
||||||
return await action()
|
return await action()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
lastError = 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))
|
await new Promise(f => setTimeout(f, 10000))
|
||||||
}
|
}
|
||||||
} while (new Date().getSeconds() < waitUntil)
|
} while (Date.now() < waitUntil)
|
||||||
throw Error('Timeout reached. Latest error: ' + lastError)
|
throw Error(
|
||||||
|
'Waiting for the artifact has timed out. Latest error was: ' +
|
||||||
|
lastError
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue