From 0f583c79582ba02b2a55cdbb6c1687ee7a58c766 Mon Sep 17 00:00:00 2001 From: Sankalp Kotewar <98868223+kotewar@users.noreply.github.com> Date: Fri, 24 Mar 2023 10:29:06 +0000 Subject: [PATCH] Removed abortcontroller --- packages/cache/package-lock.json | 12 +++--- packages/cache/src/internal/downloadUtils.ts | 40 ++++---------------- 2 files changed, 14 insertions(+), 38 deletions(-) diff --git a/packages/cache/package-lock.json b/packages/cache/package-lock.json index 5e6ffac8..f81ff99f 100644 --- a/packages/cache/package-lock.json +++ b/packages/cache/package-lock.json @@ -69,9 +69,9 @@ } }, "node_modules/@actions/io": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@actions/io/-/io-1.1.2.tgz", - "integrity": "sha512-d+RwPlMp+2qmBfeLYPLXuSRykDIFEwdTA0MMxzS9kh4kvP1ftrc/9fzy6pX6qAjthdXruHQ6/6kjT/DNo5ALuw==" + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@actions/io/-/io-1.1.3.tgz", + "integrity": "sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q==" }, "node_modules/@azure/abort-controller": { "version": "1.1.0", @@ -654,9 +654,9 @@ } }, "@actions/io": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@actions/io/-/io-1.1.2.tgz", - "integrity": "sha512-d+RwPlMp+2qmBfeLYPLXuSRykDIFEwdTA0MMxzS9kh4kvP1ftrc/9fzy6pX6qAjthdXruHQ6/6kjT/DNo5ALuw==" + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@actions/io/-/io-1.1.3.tgz", + "integrity": "sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q==" }, "@azure/abort-controller": { "version": "1.1.0", diff --git a/packages/cache/src/internal/downloadUtils.ts b/packages/cache/src/internal/downloadUtils.ts index 7e1b1e8a..d688bb40 100644 --- a/packages/cache/src/internal/downloadUtils.ts +++ b/packages/cache/src/internal/downloadUtils.ts @@ -12,8 +12,6 @@ import {SocketTimeout} from './constants' import {DownloadOptions} from '../options' import {retryHttpClientResponse} from './requestUtils' -import {AbortController} from '@azure/abort-controller' - /** * Pipes the body of a HTTP response to a stream * @@ -251,8 +249,8 @@ export async function downloadCacheStorageSDK( try { downloadProgress.startDisplayTimer() - const controller = new AbortController() - const abortSignal = controller.signal + // const controller = new AbortController() + // const abortSignal = controller.signal while (!downloadProgress.isDone()) { const segmentStart = downloadProgress.segmentOffset + downloadProgress.segmentSize @@ -263,22 +261,15 @@ export async function downloadCacheStorageSDK( ) downloadProgress.nextSegment(segmentSize) - const result = await promiseWithTimeout( - options.segmentTimeoutInMs || 3600000, - client.downloadToBuffer(segmentStart, segmentSize, { - abortSignal, + const result = await client.downloadToBuffer( + segmentStart, + segmentSize, + { concurrency: options.downloadConcurrency, onProgress: downloadProgress.onProgress() - }) + } ) - if (result === 'timeout') { - controller.abort() - throw new Error( - 'Aborting cache download as the download time exceeded the timeout.' - ) - } else if (Buffer.isBuffer(result)) { - fs.writeFileSync(fd, result) - } + fs.writeFileSync(fd, result) } } finally { downloadProgress.stopDisplayTimer() @@ -286,18 +277,3 @@ export async function downloadCacheStorageSDK( } } } - -const promiseWithTimeout = async ( - timeoutMs: number, - promise: Promise -): Promise => { - let timeoutHandle: NodeJS.Timeout - const timeoutPromise = new Promise(resolve => { - timeoutHandle = setTimeout(() => resolve('timeout'), timeoutMs) - }) - - return Promise.race([promise, timeoutPromise]).then(result => { - clearTimeout(timeoutHandle) - return result - }) -}