From 862c4e9db400bfae084be3638e22d00a68045c09 Mon Sep 17 00:00:00 2001 From: Ashwin Sangem Date: Wed, 23 Mar 2022 16:44:40 +0530 Subject: [PATCH] Cap the cache download chunk to 2 GB --- packages/cache/src/internal/downloadUtils.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/cache/src/internal/downloadUtils.ts b/packages/cache/src/internal/downloadUtils.ts index 44cf7f38..cd1c36dd 100644 --- a/packages/cache/src/internal/downloadUtils.ts +++ b/packages/cache/src/internal/downloadUtils.ts @@ -240,7 +240,8 @@ export async function downloadCacheStorageSDK( // // If the file exceeds the buffer maximum length (~1 GB on 32-bit systems and ~2 GB // on 64-bit systems), split the download into multiple segments - const maxSegmentSize = buffer.constants.MAX_LENGTH + // ~2 GB = 2147483647, beyond this, we start getting out of range error. So, capping it accordingly. + const maxSegmentSize = Math.min(2147483647, buffer.constants.MAX_LENGTH)buffer.constants.MAX_LENGTH const downloadProgress = new DownloadProgress(contentLength) const fd = fs.openSync(archivePath, 'w')