gh pr checks --watch Exits 8 for Pending Checks (Not a Failure)

lesson tools active tools/gh-pr-checks-exit-code-8.md View on GitHub

gh pr checks --watch Exits 8 for Pending Checks (Not a Failure)

Rule

When gh pr checks --watch exits with code 8, it means checks are still in progress — treat it as "try again later", not as a failure.

Context

When monitoring CI/CD status on pull requests using gh pr checks --watch. Exit code 8 signals checks are queued/pending, distinct from a real failure (exit code 1) or network error.

Detection

Observable signals:

Pattern

# Wrong: treating exit code 8 as failure
gh pr checks <PR> --watch || echo "Checks failed"

# Correct: distinguish pending from failure
gh pr checks <PR> --watch
exit_code=$?
if [ $exit_code -eq 8 ]; then
    echo "Checks still pending — wait and retry"
elif [ $exit_code -ne 0 ]; then
    echo "Checks failed with exit code $exit_code"
fi

Outcome

Related

Match Keywords

exit code 8 gh pr checks watch pending checks still pending pr checks not complete