mirror of https://github.com/actions/toolkit
Removed abortcontroller
parent
457303960f
commit
0f583c7958
|
@ -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",
|
||||
|
|
|
@ -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<Buffer>
|
||||
): Promise<unknown> => {
|
||||
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
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue