ci: fix Windows Tor bundle — drop PS7-only params from Invoke-WebRequest

The hardened PowerShell retry loop from 2c2efd8 passed -ConnectionTimeout
and -OperationTimeout to Invoke-WebRequest. Those are PowerShell 7+ only;
GitHub Actions Windows runners ship PowerShell 5.1, which rejected them
with 'ParentContainsErrorRecordException / NamedParameterNotFound' on
the first iteration of the loop, and the catch block silently counted
the syntax error as a 'failed attempt' instead of a script bug.

Result on run #28689210122: both Windows jobs (build-windows-qt,
build-windows-daemon) failed at 'Download Tor' / 'Bundle Tor for daemon'
with exit code 1 before any HTTP traffic happened. macOS + Linux passed.

Fix:
* Drop -ConnectionTimeout and -OperationTimeout (PS7-only).
* Restructure the retry loop: explicit $downloaded flag, remove the
  part-file on each attempt, throw explicitly at the end if all 3
  attempts produced no usable file. The size check (>1MB) still
  rejects 0-byte / truncated '200 OK' responses.
* Add a comment at the top of each step explaining the PS 5.1 limitation
  so the next agent doesn't re-add the PS7 params.
This commit is contained in:
Krystie
2026-07-03 18:50:10 -07:00
parent 2c2efd83fd
commit 9aff1ea098
+32 -18
View File
@@ -288,9 +288,11 @@ jobs:
- name: Download Tor - name: Download Tor
# Resilient download: archive.torproject.org occasionally times out # Resilient download: archive.torproject.org occasionally times out
# from CI egress (observed 2026-07-03: macOS job exit code 6 after # from CI egress (observed 2026-07-03: macOS job exit code 6 after
# exactly 30s of curl hang). Retries cover transient connection # exactly 30s of curl hang). Retries cover transient connection drops;
# drops; -SkipHttpErrorCheck surfaces HTTP error bodies so the next # size check rejects 0-byte "200 OK" responses from broken mirrors.
# failure isn't silent. # NOTE: Invoke-WebRequest on PowerShell 5.1 (default on Windows-latest
# runners) does NOT accept -ConnectionTimeout/-OperationTimeout — those
# are PowerShell 7+. We rely on the retry loop + size check only.
shell: powershell shell: powershell
run: | run: |
$TOR_VERSION = "15.0.9" $TOR_VERSION = "15.0.9"
@@ -298,21 +300,25 @@ jobs:
$torPath = "tor-bundle.tar.gz" $torPath = "tor-bundle.tar.gz"
$attempts = 0 $attempts = 0
$maxAttempts = 3 $maxAttempts = 3
while ($attempts -lt $maxAttempts) { $downloaded = $false
while ($attempts -lt $maxAttempts -and -not $downloaded) {
$attempts++ $attempts++
try { try {
Invoke-WebRequest -Uri $TOR_URL -OutFile $torPath -UseBasicParsing ` if (Test-Path $torPath) { Remove-Item $torPath -ErrorAction SilentlyContinue }
-ConnectionTimeout 15 -OperationTimeout 120 Invoke-WebRequest -Uri $TOR_URL -OutFile $torPath -UseBasicParsing
$size = (Get-Item $torPath).Length $size = (Get-Item $torPath).Length
if ($size -gt 1MB) { break } if ($size -gt 1MB) {
Write-Host "Download too small ($size bytes), retrying..." Write-Host "Downloaded $size bytes on attempt $attempts"
Remove-Item $torPath -ErrorAction SilentlyContinue $downloaded = $true
} else {
Write-Host "Download too small ($size bytes), retrying..."
}
} catch { } catch {
Write-Host "Download attempt $attempts failed: $_" Write-Host "Download attempt $attempts failed: $_"
if ($attempts -ge $maxAttempts) { throw }
Start-Sleep -Seconds 5 Start-Sleep -Seconds 5
} }
} }
if (-not $downloaded) { throw "Tor bundle download failed after $maxAttempts attempts" }
New-Item -ItemType Directory -Path tor-extract -Force New-Item -ItemType Directory -Path tor-extract -Force
tar -xzf tor-bundle.tar.gz -C tor-extract tar -xzf tor-bundle.tar.gz -C tor-extract
New-Item -ItemType Directory -Path tor-files -Force New-Item -ItemType Directory -Path tor-files -Force
@@ -410,7 +416,11 @@ jobs:
- name: Bundle Tor for daemon - name: Bundle Tor for daemon
# Resilient download: archive.torproject.org occasionally times out # Resilient download: archive.torproject.org occasionally times out
# from CI egress (observed 2026-07-03: macOS job exit code 6 after # from CI egress (observed 2026-07-03: macOS job exit code 6 after
# exactly 30s of curl hang). Retries cover transient connection drops. # exactly 30s of curl hang). Retries cover transient connection drops;
# size check rejects 0-byte "200 OK" responses from broken mirrors.
# NOTE: Invoke-WebRequest on PowerShell 5.1 (default on Windows-latest
# runners) does NOT accept -ConnectionTimeout/-OperationTimeout — those
# are PowerShell 7+. We rely on the retry loop + size check only.
shell: powershell shell: powershell
run: | run: |
$TOR_VERSION = "15.0.9" $TOR_VERSION = "15.0.9"
@@ -418,21 +428,25 @@ jobs:
$torPath = "tor-bundle.tar.gz" $torPath = "tor-bundle.tar.gz"
$attempts = 0 $attempts = 0
$maxAttempts = 3 $maxAttempts = 3
while ($attempts -lt $maxAttempts) { $downloaded = $false
while ($attempts -lt $maxAttempts -and -not $downloaded) {
$attempts++ $attempts++
try { try {
Invoke-WebRequest -Uri $TOR_URL -OutFile $torPath -UseBasicParsing ` if (Test-Path $torPath) { Remove-Item $torPath -ErrorAction SilentlyContinue }
-ConnectionTimeout 15 -OperationTimeout 120 Invoke-WebRequest -Uri $TOR_URL -OutFile $torPath -UseBasicParsing
$size = (Get-Item $torPath).Length $size = (Get-Item $torPath).Length
if ($size -gt 1MB) { break } if ($size -gt 1MB) {
Write-Host "Download too small ($size bytes), retrying..." Write-Host "Downloaded $size bytes on attempt $attempts"
Remove-Item $torPath -ErrorAction SilentlyContinue $downloaded = $true
} else {
Write-Host "Download too small ($size bytes), retrying..."
}
} catch { } catch {
Write-Host "Download attempt $attempts failed: $_" Write-Host "Download attempt $attempts failed: $_"
if ($attempts -ge $maxAttempts) { throw }
Start-Sleep -Seconds 5 Start-Sleep -Seconds 5
} }
} }
if (-not $downloaded) { throw "Tor bundle download failed after $maxAttempts attempts" }
New-Item -ItemType Directory -Path tor-extract -Force New-Item -ItemType Directory -Path tor-extract -Force
tar -xzf tor-bundle.tar.gz -C tor-extract tar -xzf tor-bundle.tar.gz -C tor-extract
Copy-Item -Recurse tor-extract/tor/* daemon-dist/tor/ Copy-Item -Recurse tor-extract/tor/* daemon-dist/tor/