mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-08 00:47:15 +08:00
handle download process of puppeteer not change to long (will encounter this when network disconnected when downloading)
This commit is contained in:
@@ -21,16 +21,34 @@ export const checkAndDownloadDependenciesForInit = async () => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await checkAndDownloadPuppeteer({
|
let timeoutTimer = 0
|
||||||
downloadProgressCallback(downloadedBytes: number, totalBytes: number) {
|
await new Promise((resolve, reject) => {
|
||||||
pipe?.write(
|
checkAndDownloadPuppeteer({
|
||||||
JSON.stringify({
|
downloadProgressCallback(downloadedBytes: number, totalBytes: number) {
|
||||||
type: 'PUPPETEER_DOWNLOAD_PROGRESS',
|
clearTimeout(timeoutTimer)
|
||||||
totalBytes,
|
if (downloadedBytes !== totalBytes) {
|
||||||
downloadedBytes
|
timeoutTimer = setTimeout(() => {
|
||||||
})
|
// will encounter this when network disconnected when downloading
|
||||||
) + '\r\n'
|
reject(new Error('PROGRESS_NOT_CHANGED_TOO_LONG'))
|
||||||
}
|
}, 30 * 1000)
|
||||||
|
}
|
||||||
|
console.log(downloadedBytes / totalBytes)
|
||||||
|
pipe?.write(
|
||||||
|
JSON.stringify({
|
||||||
|
type: 'PUPPETEER_DOWNLOAD_PROGRESS',
|
||||||
|
totalBytes,
|
||||||
|
downloadedBytes
|
||||||
|
})
|
||||||
|
) + '\r\n'
|
||||||
|
}
|
||||||
|
}).then(
|
||||||
|
() => {
|
||||||
|
resolve(void 0)
|
||||||
|
},
|
||||||
|
(err) => {
|
||||||
|
reject(err)
|
||||||
|
}
|
||||||
|
)
|
||||||
})
|
})
|
||||||
app.exit(DOWNLOAD_ERROR_EXIT_CODE.NO_ERROR)
|
app.exit(DOWNLOAD_ERROR_EXIT_CODE.NO_ERROR)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user