1
0
Fork 0

adds custom timeout

pull/1935/head
Prajjwal 2024-05-17 18:45:54 +05:30
parent 7efbd158ad
commit a36bdbabae
3 changed files with 25 additions and 7 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "github-actions.warp-cache", "name": "github-actions.warp-cache",
"version": "1.1.10", "version": "1.1.11",
"preview": true, "preview": true,
"description": "Github action to use WarpBuild's in-house cache offering", "description": "Github action to use WarpBuild's in-house cache offering",
"keywords": [ "keywords": [

View File

@ -254,8 +254,7 @@ export async function downloadCacheSingleThread(
retryOptions: { retryOptions: {
autoRetry: false, autoRetry: false,
maxRetries: 1 maxRetries: 1
}, }
timeout: 300
}) })
await downloadCacheGCP(storage, archiveLocation, archivePath) await downloadCacheGCP(storage, archiveLocation, archivePath)
break break

View File

@ -327,13 +327,32 @@ export async function downloadCacheGCP(
archivePath: string archivePath: string
) { ) {
try { try {
const timeoutDuration = 300000 // 5 minutes
const timeoutPromise = new Promise((_, reject) =>
setTimeout(() => reject(new Error('Download timed out')), timeoutDuration)
)
const {bucketName, objectName} = const {bucketName, objectName} =
utils.retrieveGCSBucketAndObjectName(archiveLocation) utils.retrieveGCSBucketAndObjectName(archiveLocation)
await storage.bucket(bucketName).file(objectName).download({ const downloadPromise = storage
.bucket(bucketName)
.file(objectName)
.download({
destination: archivePath, destination: archivePath,
validation: 'crc32c' 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) { } catch (error) {
core.debug(`Failed to download cache: ${error}`) core.debug(`Failed to download cache: ${error}`)
throw error throw error