Files
hyperframes/scripts/ci/install-workspace-dependencies.sh
T
Miguel Angel Simon Sierra 7ff370de5c fix(ci): kill the Windows child via taskkill, not a signal
Review found kill -TERM against a native Windows binary (bun.exe)
under Git Bash is best-effort thread injection, not a real
signal, and can fail to land -- reproducing the exact hang this
watchdog exists to prevent. taskkill //F //T is a real
TerminateProcess call.

Also: cite the run id instead of a branch name (branches get
deleted), and add the missing shell: bash the repo's other
Windows steps already set explicitly.
2026-09-19 19:17:17 -04:00

55 lines
1.7 KiB
Bash

#!/usr/bin/env bash
set -u
max_attempts=3
retry_delay_seconds="${HF_BUN_INSTALL_RETRY_DELAY_SECONDS:-5}"
install_timeout_seconds="${HF_BUN_INSTALL_TIMEOUT_SECONDS:-300}"
# Portable: this runs on ubuntu/macos/windows(Git Bash), and GNU `timeout`
# is not reliably present there (macOS has none by default). A hung bun
# install errors then never exits (see fix/regression-docker-build-timeout),
# so without this the retry loop below never fires.
run_with_timeout() {
local seconds=$1
shift
"$@" &
local pid=$!
local elapsed=0
while kill -0 "$pid" 2>/dev/null; do
if ((elapsed >= seconds)); then
# Git Bash's `kill -TERM` on a native Windows binary (bun.exe) is a
# best-effort thread-injection emulation, not a real signal, and can
# fail to land -- the exact hang this function exists to prevent.
# taskkill //T (kills the child tree) //F (TerminateProcess) is real.
if [[ "${OS:-}" == "Windows_NT" ]]; then
taskkill //F //T //PID "$pid" 2>/dev/null
else
kill -TERM "$pid" 2>/dev/null
fi
wait "$pid" 2>/dev/null
return 124
fi
sleep 1
elapsed=$((elapsed + 1))
done
wait "$pid"
}
for ((attempt = 1; attempt <= max_attempts; attempt += 1)); do
if run_with_timeout "$install_timeout_seconds" bun install --frozen-lockfile "$@"; then
exit 0
else
install_status=$?
fi
if ((attempt == max_attempts)); then
echo "::error::Bun dependency install failed after ${max_attempts} attempts."
exit "$install_status"
fi
next_attempt=$((attempt + 1))
echo "::warning::Bun dependency install failed; retrying dependency install (attempt ${next_attempt}/${max_attempts})."
sleep "$((retry_delay_seconds * attempt))"
done