mirror of https://github.com/actions/toolkit
add timeout in between data chunks
parent
2d6ba67518
commit
34a411f3c0
|
@ -67,11 +67,30 @@ async function streamExtractInternal(
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const zipStream = unzip.Extract({path: directory})
|
const zipStream = unzip.Extract({path: directory})
|
||||||
|
|
||||||
|
const timeout = 30 * 1000
|
||||||
|
const timerFn = (): void => {
|
||||||
|
throw new Error(`Blob storage chunk did not respond in ${timeout}ms `)
|
||||||
|
}
|
||||||
|
let timer = setTimeout(timerFn, timeout)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
response.message.pipe(zipStream).on('close', resolve).on('error', reject)
|
response.message
|
||||||
|
.on('data', () => {
|
||||||
|
clearTimeout(timer)
|
||||||
|
timer = setTimeout(timerFn, timeout)
|
||||||
|
})
|
||||||
|
.pipe(zipStream)
|
||||||
|
.on('close', () => {
|
||||||
|
clearTimeout(timer)
|
||||||
|
resolve()
|
||||||
|
})
|
||||||
|
.on('error', reject)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
zipStream.end()
|
zipStream.end()
|
||||||
reject(error)
|
reject(error)
|
||||||
|
} finally {
|
||||||
|
clearTimeout(timer)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue