Diffinery

codician/diffinerypublic

Open-source, agent-first GitHub and GitHub Actions alternative that runs on your own Cloudflare account: git hosting, pull requests, code review and drop-in GitHub Actions YAML on Workers, Durable Objects, R2 and Containers.

Sync: a dropped connection to Diffinery no longer fails the wait (#73)

The main sync for a2120c0 failed after 15 minutes of waiting with "curl: (35)
Recv failure: Connection reset by peer": curl's --retry doesn't retry a reset
connection, and under `set -e` one failed poll ended the step without saying
how the runs went. Requests now retry on any error, and a poll that still fails
is logged and repeated until the time limit.


Claude-Session: https://claude.ai/code/session_01Ruyx3Qr4jYrZEpPi466deb

Co-authored-by: Claude <noreply@anthropic.com>
Canberk Demirci authored · GitHub committed signed1 parent 2fd1b06commit 9c9b881bb3af2b767f5aea42281465bf89899bb0Browse files
1 file changed+9−2
modifiedscripts/diffinery-wait-runs.sh+9−2View file
@@ -9,13 +9,20 @@
99 # Usage: DIFFINERY=https://diffinery.com TOKEN=... diffinery-wait-runs.sh owner/repo sha [minutes]
1010 set -euo pipefail
1111 repo=$1 sha=$2 minutes=${3:-60}
12-api() { curl -fsS --retry 3 "$DIFFINERY/api/v3/repos/$repo$1" -H "Authorization: Bearer $TOKEN"; }
12+# --retry-all-errors also retries a reset connection, which plain --retry gives up on.
13+api() { curl -fsS --retry 4 --retry-all-errors --retry-delay 3 "$DIFFINERY/api/v3/repos/$repo$1" -H "Authorization: Bearer $TOKEN"; }
1314 unrelated='["workflow_dispatch", "schedule", "repository_dispatch"]'
1415
1516 deadline=$(( $(date +%s) + minutes * 60 ))
1617 settled=0
1718 while :; do
18- all=$(api "/actions/runs?head_sha=$sha&per_page=100")
19+ # One failed poll (the network, a deploy in progress) is not a result: poll again.
20+ if ! all=$(api "/actions/runs?head_sha=$sha&per_page=100"); then
21+ echo "::warning::could not list the runs at $(date -u +%T); polling again"
22+ [ "$(date +%s)" -lt "$deadline" ] || { echo "::error::Diffinery was unreachable at the $minutes minute limit"; exit 1; }
23+ sleep 15
24+ continue
25+ fi
1926 runs=$(jq --argjson u "$unrelated" '.workflow_runs |= map(select(.event as $e | $u | index($e) | not))' <<<"$all")
2027 total=$(jq '.workflow_runs | length' <<<"$runs")
2128 pending=$(jq '[.workflow_runs[] | select(.status != "completed")] | length' <<<"$runs")