mirror of https://github.com/actions/toolkit
Added abort controller for timer
parent
e5e69a3171
commit
970264135a
|
@ -251,6 +251,7 @@ export async function downloadCacheStorageSDK(
|
||||||
try {
|
try {
|
||||||
downloadProgress.startDisplayTimer()
|
downloadProgress.startDisplayTimer()
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
|
const timerController = new AbortController();
|
||||||
const abortSignal = controller.signal;
|
const abortSignal = controller.signal;
|
||||||
while (!downloadProgress.isDone()) {
|
while (!downloadProgress.isDone()) {
|
||||||
const segmentStart =
|
const segmentStart =
|
||||||
|
@ -262,7 +263,6 @@ export async function downloadCacheStorageSDK(
|
||||||
)
|
)
|
||||||
|
|
||||||
downloadProgress.nextSegment(segmentSize)
|
downloadProgress.nextSegment(segmentSize)
|
||||||
|
|
||||||
const result = await Promise.race([client.downloadToBuffer(
|
const result = await Promise.race([client.downloadToBuffer(
|
||||||
segmentStart,
|
segmentStart,
|
||||||
segmentSize,
|
segmentSize,
|
||||||
|
@ -272,11 +272,14 @@ export async function downloadCacheStorageSDK(
|
||||||
onProgress: downloadProgress.onProgress()
|
onProgress: downloadProgress.onProgress()
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
timer.setTimeout(options.abortTimeInMs, 'timeout')]);
|
timer.setTimeout(options.abortTimeInMs, 'timeout',{ signal: timerController.signal })]);
|
||||||
|
|
||||||
if(result === 'timeout') {
|
if(result === 'timeout') {
|
||||||
controller.abort();
|
controller.abort();
|
||||||
throw new Error("Download aborted, segment download timed out.");
|
throw new Error("Download aborted, segment download timed out.");
|
||||||
|
} else {
|
||||||
|
timerController.abort();
|
||||||
|
core.debug("Download completely successfully, cancelling timer.")
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.writeFileSync(fd, result)
|
fs.writeFileSync(fd, result)
|
||||||
|
|
Loading…
Reference in New Issue