From c3f75ccf13e8c46360d3edaac0f805ddd80206b8 Mon Sep 17 00:00:00 2001 From: nexryai Date: Mon, 12 Jan 2026 21:41:17 +0900 Subject: [PATCH] Implement a timeout for downloads --- src/index.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/index.ts b/src/index.ts index 1905e91..9d8558d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -304,10 +304,18 @@ async function streamDownloadFromDrive(accessToken: string, bucket: string, obje throw new Error("File not found"); } + const controller = new AbortController(); + const timeout = setTimeout(() => { + controller.abort(); + }, 5000); + const downloadRes = await fetch(`https://www.googleapis.com/drive/v3/files/${file.id}?alt=media`, { headers: { Authorization: `Bearer ${accessToken}` }, + signal: controller.signal, }); + clearTimeout(timeout); + if (!downloadRes.ok) { console.error(downloadRes.status); console.error(await downloadRes.text());