mirror of
https://github.com/Nezumi-2711/google-drive-s3.git
synced 2026-09-22 13:38:30 +00:00
Implement a timeout for downloads
This commit is contained in:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user