From 165a33eeceee090fb215978aa11dd09ce73dfcca Mon Sep 17 00:00:00 2001 From: metaphorics <152830360+metaphorics@users.noreply.github.com> Date: Thu, 2 Jul 2026 17:25:50 +0900 Subject: [PATCH] fix(install): add network timeouts to install script downloads The GitHub API and binary download calls in `install_binary()` (`scripts/install.sh`) and `Install-Binary` (`scripts/install.ps1`) could hang indefinitely on stalled connections. Added curl `--connect-timeout`/`--max-time` to the release metadata calls and `--connect-timeout`/`--speed-limit`/`--speed-time` to the binary download, plus `-TimeoutSec` to the PowerShell `Invoke-RestMethod`/`Invoke-WebRequest` calls. Verified `bash -n scripts/install.sh` passes; no TypeScript typecheck is affected. Closes #4253 --- scripts/install.ps1 | 6 +++--- scripts/install.sh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/install.ps1 b/scripts/install.ps1 index 70c2288cc..cb26ada9b 100755 --- a/scripts/install.ps1 +++ b/scripts/install.ps1 @@ -239,13 +239,13 @@ function Install-Binary { if ($Ref) { Write-Host "Fetching release $Ref..." try { - $Release = Invoke-RestMethod -Uri "https://api.github.com/repos/$Repo/releases/tags/$Ref" + $Release = Invoke-RestMethod -Uri "https://api.github.com/repos/$Repo/releases/tags/$Ref" -TimeoutSec 60 } catch { throw "Release tag not found: $Ref`nFor branch/commit installs, use -Source with -Ref." } } else { Write-Host "Fetching latest release..." - $Release = Invoke-RestMethod -Uri "https://api.github.com/repos/$Repo/releases/latest" + $Release = Invoke-RestMethod -Uri "https://api.github.com/repos/$Repo/releases/latest" -TimeoutSec 60 } $Latest = $Release.tag_name @@ -260,7 +260,7 @@ function Install-Binary { $BinaryUrl = "https://github.com/$Repo/releases/download/$Latest/$BinaryName" Write-Host "Downloading $BinaryName..." $OutPath = Join-Path $InstallDir "omp.exe" - Invoke-WebRequest -Uri $BinaryUrl -OutFile $OutPath + Invoke-WebRequest -Uri $BinaryUrl -OutFile $OutPath -TimeoutSec 900 Write-Host "" Write-Host "✓ Installed omp to $OutPath" -ForegroundColor Green diff --git a/scripts/install.sh b/scripts/install.sh index d65859483..b7ef48098 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -205,7 +205,7 @@ install_binary() { # Get release tag if [ -n "$REF" ]; then echo "Fetching release $REF..." - if RELEASE_JSON=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/tags/${REF}"); then + if RELEASE_JSON=$(curl -fsSL --connect-timeout 10 --max-time 60 "https://api.github.com/repos/${REPO}/releases/tags/${REF}"); then LATEST=$(echo "$RELEASE_JSON" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/') else echo "Release tag not found: $REF" @@ -214,7 +214,7 @@ install_binary() { fi else echo "Fetching latest release..." - RELEASE_JSON=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest") + RELEASE_JSON=$(curl -fsSL --connect-timeout 10 --max-time 60 "https://api.github.com/repos/${REPO}/releases/latest") LATEST=$(echo "$RELEASE_JSON" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/') fi @@ -228,7 +228,7 @@ install_binary() { # Download binary BINARY_URL="https://github.com/${REPO}/releases/download/${LATEST}/${BINARY}" echo "Downloading ${BINARY}..." - curl -fsSL "$BINARY_URL" -o "${INSTALL_DIR}/omp" + curl -fsSL --connect-timeout 10 --speed-limit 1024 --speed-time 30 "$BINARY_URL" -o "${INSTALL_DIR}/omp" chmod +x "${INSTALL_DIR}/omp" echo "" echo "✓ Installed omp to ${INSTALL_DIR}/omp"