Skip to content

Commit a409dae

Browse files
committed
fix(docs): retry forge build to handle transient solc download DNS failures
1 parent db4ec58 commit a409dae

1 file changed

Lines changed: 24 additions & 5 deletions

File tree

docs/examples/bootstrap.sh

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,36 @@ function compile-solidity {
9696

9797
mkdir -p "$OUTPUT_DIR"
9898

99-
# Compile using the local foundry.toml with proper remappings
99+
# forge build downloads solc from binaries.soliditylang.org on first use,
100+
# which has hit transient DNS / connect failures in CI. Retry with backoff
101+
# so a flaky network does not fail the merge train.
102+
local max_attempts=5
103+
local attempt
104+
local backoff
100105
(
101106
cd "$SOLIDITY_DIR"
102107
for subdir in */; do
103108
if [ -d "$subdir" ] && ls "$subdir"/*.sol >/dev/null 2>&1; then
104109
local subdir_name=$(basename "$subdir")
105110
echo_stderr "Compiling $subdir_name..."
106-
forge build \
107-
--contracts "$subdir" \
108-
--out "$OUTPUT_DIR/$subdir_name" \
109-
--no-cache
111+
attempt=1
112+
backoff=5
113+
while true; do
114+
if forge build \
115+
--contracts "$subdir" \
116+
--out "$OUTPUT_DIR/$subdir_name" \
117+
--no-cache; then
118+
break
119+
fi
120+
if (( attempt >= max_attempts )); then
121+
echo_stderr "forge build for $subdir_name failed after $attempt attempts"
122+
return 1
123+
fi
124+
echo_stderr "forge build for $subdir_name failed (attempt $attempt/$max_attempts), retrying in ${backoff}s..."
125+
sleep "$backoff"
126+
attempt=$((attempt + 1))
127+
backoff=$((backoff * 2))
128+
done
110129
fi
111130
done
112131
)

0 commit comments

Comments
 (0)