Skip to content

Commit 401c464

Browse files
committed
feat: add timeout handling for downloadFile function
1 parent de9aec7 commit 401c464

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

scripts/download-binaries.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ type Architecture = keyof typeof RUST_TARGET_TRIPLES[Platform];
3737

3838
async function downloadFile(url: string, dest: string): Promise<void> {
3939
const streamPipeline = promisify(pipeline);
40-
const response = await fetch(url);
40+
const controller = new AbortController();
41+
const timeoutId = setTimeout(() => controller.abort(), 60000); // 60 seconds timeout
42+
43+
const response = await fetch(url, {
44+
signal: controller.signal,
45+
}).finally(() => clearTimeout(timeoutId));
4146

4247
if (!response.ok) {
4348
throw new Error(`Download failed: '${url}' (${response.status})`);

0 commit comments

Comments
 (0)