From 222733049e3dc37adf0f8fc8c18e1f08ea548976 Mon Sep 17 00:00:00 2001 From: Vallie Joseph Date: Tue, 9 Apr 2024 21:22:40 +0000 Subject: [PATCH] . --- packages/artifact/src/internal/upload/blob-upload.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/artifact/src/internal/upload/blob-upload.ts b/packages/artifact/src/internal/upload/blob-upload.ts index 1fbdf771..f08bbe81 100644 --- a/packages/artifact/src/internal/upload/blob-upload.ts +++ b/packages/artifact/src/internal/upload/blob-upload.ts @@ -27,8 +27,13 @@ export async function uploadZipToBlobStorage( let lastProgressTime = Date.now() let timeoutId: NodeJS.Timeout | undefined - const chunkTimer = (timeout: number): NodeJS.Timeout => - setTimeout(() => { + const chunkTimer = (timeout: number): NodeJS.Timeout => { + // clear the previous timeout + if (timeoutId) { + clearTimeout(timeoutId) + } + + timeoutId = setTimeout(() => { const now = Date.now() // if there's been more than 30 seconds since the // last progress event, then we'll consider the upload stalled @@ -36,6 +41,8 @@ export async function uploadZipToBlobStorage( throw new Error('Upload progress stalled.') } }, timeout) + return timeoutId + } const maxConcurrency = getConcurrency() const bufferSize = getUploadChunkSize() const blobClient = new BlobClient(authenticatedUploadURL)