mirror of https://github.com/actions/toolkit
adds custom timeout
parent
7efbd158ad
commit
a36bdbabae
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "github-actions.warp-cache",
|
||||
"version": "1.1.10",
|
||||
"version": "1.1.11",
|
||||
"preview": true,
|
||||
"description": "Github action to use WarpBuild's in-house cache offering",
|
||||
"keywords": [
|
||||
|
|
|
@ -254,8 +254,7 @@ export async function downloadCacheSingleThread(
|
|||
retryOptions: {
|
||||
autoRetry: false,
|
||||
maxRetries: 1
|
||||
},
|
||||
timeout: 300
|
||||
}
|
||||
})
|
||||
await downloadCacheGCP(storage, archiveLocation, archivePath)
|
||||
break
|
||||
|
|
|
@ -327,13 +327,32 @@ export async function downloadCacheGCP(
|
|||
archivePath: string
|
||||
) {
|
||||
try {
|
||||
const timeoutDuration = 300000 // 5 minutes
|
||||
|
||||
const timeoutPromise = new Promise((_, reject) =>
|
||||
setTimeout(() => reject(new Error('Download timed out')), timeoutDuration)
|
||||
)
|
||||
|
||||
const {bucketName, objectName} =
|
||||
utils.retrieveGCSBucketAndObjectName(archiveLocation)
|
||||
|
||||
await storage.bucket(bucketName).file(objectName).download({
|
||||
destination: archivePath,
|
||||
validation: 'crc32c'
|
||||
})
|
||||
const downloadPromise = storage
|
||||
.bucket(bucketName)
|
||||
.file(objectName)
|
||||
.download({
|
||||
destination: archivePath,
|
||||
validation: 'crc32c'
|
||||
})
|
||||
|
||||
try {
|
||||
await Promise.race([downloadPromise, timeoutPromise])
|
||||
core.debug(
|
||||
`Download completed for bucket: ${bucketName}, object: ${objectName}`
|
||||
)
|
||||
} catch (error) {
|
||||
core.debug(`Failed to download cache: ${error}`)
|
||||
throw error
|
||||
}
|
||||
} catch (error) {
|
||||
core.debug(`Failed to download cache: ${error}`)
|
||||
throw error
|
||||
|
|
Loading…
Reference in New Issue