From 5f45309eed6aedb5250b8c464c4db714bca8f545 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Fri, 13 Jun 2025 16:44:28 +0000 Subject: [PATCH] Fix install script race condition by eliminating separate HEAD request - Remove separate curl --head check that created race condition window - Use single curl -L --fail request with retry logic (3 attempts) - Add 2-second delay between retries with progress feedback - Maintains all existing functionality while eliminating timing issues Fixes flaky CI test failures caused by checksum verification mismatches when CDN/cache serves different versions between HEAD and GET requests. Co-Authored-By: jhaynie@agentuity.com --- install.sh | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/install.sh b/install.sh index ddb1c06b..af8a6cba 100755 --- a/install.sh +++ b/install.sh @@ -248,12 +248,24 @@ download_release() { debug " > DOWNLOAD_FILENAME: $DOWNLOAD_FILENAME" debug " > TMP_DIR: $TMP_DIR" - if curl --head --silent --fail "$DOWNLOAD_URL" > /dev/null 2>&1; then - ohai "Downloading Agentuity CLI v${VERSION} for ${OS}/${ARCH}..." - curl -L --progress-bar "$DOWNLOAD_URL" -o "$TMP_DIR/$DOWNLOAD_FILENAME" || abort "Failed to download from $DOWNLOAD_URL" - else - abort "Failed to download from $DOWNLOAD_URL" - fi + ohai "Downloading Agentuity CLI v${VERSION} for ${OS}/${ARCH}..." + + RETRY_COUNT=0 + MAX_RETRIES=3 + + while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do + if curl -L --fail --progress-bar "$DOWNLOAD_URL" -o "$TMP_DIR/$DOWNLOAD_FILENAME"; then + break + else + RETRY_COUNT=$((RETRY_COUNT + 1)) + if [ $RETRY_COUNT -lt $MAX_RETRIES ]; then + warn "Download failed, retrying in 2 seconds... (attempt $RETRY_COUNT/$MAX_RETRIES)" + sleep 2 + else + abort "Failed to download from $DOWNLOAD_URL after $MAX_RETRIES attempts" + fi + fi + done }