From 40081da2ddea5f480d2efa0ee4710f3aa5794dd4 Mon Sep 17 00:00:00 2001 From: sharon Date: Fri, 18 Oct 2024 14:10:26 -0400 Subject: [PATCH] increase `quarto` fetch timeout to 90 seconds (#5064) ### Summary - this change resolves an issue with the quarto download taking too long, causing a local release build to fail - added new property `timeoutSeconds` to `IFetchOptions`, which can be used to set a different timeout than the default 30 seconds - set `timeoutSeconds` to 90s for quarto downloads, which were taking upwards of 50 seconds to download on my machine - ran `yarn compile` in the `build` directory to update the corresponding `.js` files ### Background The quarto download was failing for me on Mac: ``` [14:52:05] Synchronizing quarto 1.5.55... [14:52:05] [Fetch queue] start fetching https://github.com/quarto-dev/quarto-cli/releases/download/v1.5.55/quarto-1.5.55-macos.tar.gz (0 remaining) [14:52:05] Start fetching https://github.com/quarto-dev/quarto-cli/releases/download/v1.5.55/quarto-1.5.55-macos.tar.gz [14:52:08] Fetch completed: Status 200. Took 2593 ms [14:52:35] Fetching https://github.com/quarto-dev/quarto-cli/releases/download/v1.5.55/quarto-1.5.55-macos.tar.gz failed: AbortError: This operation was aborted [14:52:36] Start fetching https://github.com/quarto-dev/quarto-cli/releases/download/v1.5.55/quarto-1.5.55-macos.tar.gz (1 retry) [14:52:37] Fetch completed: Status 200. Took 353 ms [14:53:06] Fetching https://github.com/quarto-dev/quarto-cli/releases/download/v1.5.55/quarto-1.5.55-macos.tar.gz failed: AbortError: This operation was aborted ... [14:57:15] Start fetching https://github.com/quarto-dev/quarto-cli/releases/download/v1.5.55/quarto-1.5.55-macos.tar.gz (10 retry) [14:57:16] Fetch completed: Status 200. Took 243 ms [14:57:45] Fetching https://github.com/quarto-dev/quarto-cli/releases/download/v1.5.55/quarto-1.5.55-macos.tar.gz failed: AbortError: This operation was aborted [14:57:45] [Fetch queue] failed fetching https://github.com/quarto-dev/quarto-cli/releases/download/v1.5.55/quarto-1.5.55-macos.tar.gz (0 remaining): AbortError: This operation was aborted [14:57:45] 'vscode' errored after 48 min [14:57:45] AbortError: This operation was aborted at new DOMException (node:internal/per_context/domexception:53:5) at AbortController.abort (node:internal/abort_controller:392:18) at Timeout._onTimeout (/Users/sashimi/dev/positron-dev/build/lib/fetch.js:50:53) at listOnTimeout (node:internal/timers:573:17) ``` ### QA Notes Running release builds should no longer timeout on the quarto step as long as it takes no more than 90 seconds. --- build/lib/fetch.js | 5 ++++- build/lib/fetch.ts | 8 +++++++- build/lib/quarto.js | 3 +++ build/lib/quarto.ts | 3 +++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/build/lib/fetch.js b/build/lib/fetch.js index 31a3447982d..4f7af522b5b 100644 --- a/build/lib/fetch.js +++ b/build/lib/fetch.js @@ -47,7 +47,10 @@ async function fetchUrl(url, options, retries = 10, retryDelay = 1000) { startTime = new Date().getTime(); } const controller = new AbortController(); - const timeout = setTimeout(() => controller.abort(), 30 * 1000); + // --- Start Positron --- + const timeoutSeconds = options.timeoutSeconds ?? 30; + const timeout = setTimeout(() => controller.abort(), timeoutSeconds * 1000); + // --- End Positron --- try { const response = await fetch(url, { ...options.nodeFetchOptions, diff --git a/build/lib/fetch.ts b/build/lib/fetch.ts index 200e9b3e7a5..0eed6b0e608 100644 --- a/build/lib/fetch.ts +++ b/build/lib/fetch.ts @@ -20,6 +20,9 @@ export interface IFetchOptions { nodeFetchOptions?: RequestInit; verbose?: boolean; checksumSha256?: string; + // --- Start Positron --- + timeoutSeconds?: number; + // --- End Positron --- } export function fetchUrls(urls: string[] | string, options: IFetchOptions): es.ThroughStream { @@ -58,7 +61,10 @@ export async function fetchUrl(url: string, options: IFetchOptions, retries = 10 startTime = new Date().getTime(); } const controller = new AbortController(); - const timeout = setTimeout(() => controller.abort(), 30 * 1000); + // --- Start Positron --- + const timeoutSeconds = options.timeoutSeconds ?? 30; + const timeout = setTimeout(() => controller.abort(), timeoutSeconds * 1000); + // --- End Positron --- try { const response = await fetch(url, { ...options.nodeFetchOptions, diff --git a/build/lib/quarto.js b/build/lib/quarto.js index 4dd0852ecbe..b872f7d3897 100644 --- a/build/lib/quarto.js +++ b/build/lib/quarto.js @@ -32,6 +32,7 @@ function getQuartoWindows(version) { return (0, fetch_1.fetchUrls)([`${basename}.zip`], { base: getBaseUrl(version), verbose: true, + timeoutSeconds: 90, }) .pipe(unzip()); } @@ -47,6 +48,7 @@ function getQuartoMacOS(version) { return (0, fetch_1.fetchUrls)([`quarto-${version}-macos.tar.gz`], { base: getBaseUrl(version), verbose: true, + timeoutSeconds: 90, }) // Unzip, then untar .pipe(gunzip()) @@ -67,6 +69,7 @@ function getQuartoLinux(version) { return (0, fetch_1.fetchUrls)([`${basename}.tar.gz`], { base: getBaseUrl(version), verbose: true, + timeoutSeconds: 90, }) // Unzip, then untar .pipe(gunzip()) diff --git a/build/lib/quarto.ts b/build/lib/quarto.ts index 555aafc8458..50f2679f3ef 100644 --- a/build/lib/quarto.ts +++ b/build/lib/quarto.ts @@ -32,6 +32,7 @@ function getQuartoWindows(version: string): Stream { return fetchUrls([`${basename}.zip`], { base: getBaseUrl(version), verbose: true, + timeoutSeconds: 90, }) .pipe(unzip()); } @@ -49,6 +50,7 @@ function getQuartoMacOS(version: string): Stream { return fetchUrls([`quarto-${version}-macos.tar.gz`], { base: getBaseUrl(version), verbose: true, + timeoutSeconds: 90, }) // Unzip, then untar .pipe(gunzip()) @@ -72,6 +74,7 @@ function getQuartoLinux(version: string): Stream { return fetchUrls([`${basename}.tar.gz`], { base: getBaseUrl(version), verbose: true, + timeoutSeconds: 90, }) // Unzip, then untar .pipe(gunzip())