1
0
Fork 0

Hack for timeout for segment download

pull/1140/head
Bishal Prasad 2022-07-29 12:37:50 +05:30 committed by GitHub
parent 01e1ff7bc0
commit 9b309c5a32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 8 deletions

View File

@ -6,6 +6,7 @@ import * as buffer from 'buffer'
import * as fs from 'fs'
import * as stream from 'stream'
import * as util from 'util'
import * as timer from 'timers/promises'
import * as utils from './cacheUtils'
import {SocketTimeout} from './constants'
@ -259,14 +260,19 @@ export async function downloadCacheStorageSDK(
downloadProgress.nextSegment(segmentSize)
const result = await client.downloadToBuffer(
segmentStart,
segmentSize,
{
concurrency: options.downloadConcurrency,
onProgress: downloadProgress.onProgress()
}
)
const result = await Promise.Race([client.downloadToBuffer(
segmentStart,
segmentSize,
{
concurrency: options.downloadConcurrency,
onProgress: downloadProgress.onProgress()
}
),
timer.setTimeout(60 * 60 * 1000, 'timeout')]);
if(result === 'timeout') {
throw new Error("Segment download timed out");
}
fs.writeFileSync(fd, result)
}