From 6c8c6ca9d9a858fa17c4a3dfb456e4198564602f Mon Sep 17 00:00:00 2001 From: Brian 'bdougie' Douglas Date: Fri, 29 Aug 2025 11:51:58 -0700 Subject: [PATCH] fix: Add timeout to CLI commands to prevent workflow hanging - Add 10 second timeout for CLI version check - Add 120 second timeout for main CLI execution - Prevents workflows from timing out (10 minute GitHub Actions limit) - Ensures graceful failure with fallback messages if CLI hangs --- actions/detailed-review/action.yml | 5 +++-- actions/general-review/action.yml | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/actions/detailed-review/action.yml b/actions/detailed-review/action.yml index 407c8e701..bf26ca06d 100644 --- a/actions/detailed-review/action.yml +++ b/actions/detailed-review/action.yml @@ -219,7 +219,7 @@ runs: # Test Continue CLI availability if [ "$SKIP_CLI" != "true" ]; then echo "Testing Continue CLI..." - if ! cn --version; then + if ! timeout 10 cn --version; then echo "Warning: Continue CLI not found or not working" cat > inline_review.json << 'EOF' { @@ -234,7 +234,8 @@ runs: # Run the CLI and capture JSON output with error handling if [ "$SKIP_CLI" != "true" ]; then echo "Executing Continue CLI with org: ${{ inputs.continue-org }}, config: ${{ inputs.continue-config }}" - if ! cn --readonly --format json --org "${{ inputs.continue-org }}" --config "${{ inputs.continue-config }}" -p "$(cat inline_review_prompt.txt)" > inline_review_raw.json 2>cli_error.log; then + # Use timeout to prevent hanging (120 seconds max) + if ! timeout 120 cn --readonly --format json --org "${{ inputs.continue-org }}" --config "${{ inputs.continue-config }}" -p "$(cat inline_review_prompt.txt)" > inline_review_raw.json 2>cli_error.log; then echo "Warning: Continue CLI command failed" echo "CLI error log:" cat cli_error.log diff --git a/actions/general-review/action.yml b/actions/general-review/action.yml index f90bd398c..51c2812d3 100644 --- a/actions/general-review/action.yml +++ b/actions/general-review/action.yml @@ -189,7 +189,7 @@ EOF # Test Continue CLI availability if [ "$SKIP_CLI" != "true" ]; then echo "Testing Continue CLI..." - if ! cn --version; then + if ! timeout 10 cn --version; then echo "Warning: Continue CLI not found or not working" cat > code_review.md << 'EOF' ## Code Review Summary @@ -207,7 +207,8 @@ EOF # Run the CLI with validated config and error handling if [ "$SKIP_CLI" != "true" ]; then echo "Executing Continue CLI with org: $CONTINUE_ORG, config: $CONTINUE_CONFIG" - if ! cn --readonly --org "$CONTINUE_ORG" --config "$CONTINUE_CONFIG" -p "$(cat review_prompt.txt)" > code_review.md 2>cli_error.log; then + # Use timeout to prevent hanging (120 seconds max) + if ! timeout 120 cn --readonly --org "$CONTINUE_ORG" --config "$CONTINUE_CONFIG" -p "$(cat review_prompt.txt)" > code_review.md 2>cli_error.log; then echo "Error: Continue CLI command failed" echo "CLI error log:" cat cli_error.log