From 33145fa4b6725293bb9d5a1c83a9522661fd2bf5 Mon Sep 17 00:00:00 2001 From: Miguel Angel Simon Sierra Date: Sat, 19 Sep 2026 18:28:22 -0400 Subject: [PATCH] fix(ci): bound the last unguarded bun installs against a hang Same defect as #4204/#4206: an erroring bun install (corrupt tarball extraction) can hang instead of exiting, eating a full job timeout. - install-workspace-dependencies.sh: portable bash-only watchdog (no GNU `timeout` on macOS/Windows runners) so its own retry loop can actually fire on a hang. - k8s-jobs/Dockerfile.example: same timeout+retry as the other two fixed Dockerfiles (Debian base, GNU timeout available). - ci.yml: route the bare Windows install step through the now guarded script instead of a raw bun install. Nothing else in this class is left. Claude-Session: https://claude.ai/code/session_018Ne5CfTmFV6GStSKZDf2dy --- .github/workflows/ci.yml | 2 +- examples/k8s-jobs/Dockerfile.example | 4 +++- scripts/ci/install-workspace-dependencies.sh | 25 +++++++++++++++++++- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a7489c3f14..ecebe78eed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -508,7 +508,7 @@ jobs: run: bash scripts/ci/install-workspace-dependencies.sh --ignore-scripts - name: Install dependencies if: runner.os == 'Windows' - run: bun install --frozen-lockfile --ignore-scripts --linker=hoisted + run: bash scripts/ci/install-workspace-dependencies.sh --ignore-scripts --linker=hoisted - run: bun run --cwd packages/cli test src/utils/npxCommand.test.ts src/commands/skills.test.ts sdk-tests: diff --git a/examples/k8s-jobs/Dockerfile.example b/examples/k8s-jobs/Dockerfile.example index 56d1510ab4..e35248125a 100644 --- a/examples/k8s-jobs/Dockerfile.example +++ b/examples/k8s-jobs/Dockerfile.example @@ -104,8 +104,10 @@ COPY packages/core/package.json packages/core/ COPY packages/engine/package.json packages/engine/ COPY packages/producer/package.json packages/producer/ +# A corrupt tarball extraction can print an error and then hang instead of +# exiting (fix/regression-docker-build-timeout). Bound each attempt and retry. RUN npm install --global bun && \ - bun install --frozen-lockfile && \ + (timeout 300 bun install --frozen-lockfile || timeout 300 bun install --frozen-lockfile) && \ npm uninstall --global bun # Bring in the source. We're not building the producer's dist/ here — bun's diff --git a/scripts/ci/install-workspace-dependencies.sh b/scripts/ci/install-workspace-dependencies.sh index 93018bf4ad..c7641cc7c9 100644 --- a/scripts/ci/install-workspace-dependencies.sh +++ b/scripts/ci/install-workspace-dependencies.sh @@ -4,9 +4,32 @@ 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 + kill -TERM "$pid" 2>/dev/null + 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 bun install --frozen-lockfile "$@"; then + if run_with_timeout "$install_timeout_seconds" bun install --frozen-lockfile "$@"; then exit 0 else install_status=$?