From f4a10157c3f4305287c27a8a9a920da91545ccae Mon Sep 17 00:00:00 2001 From: Gorka Date: Wed, 18 Mar 2026 16:42:28 -0300 Subject: [PATCH] fix(lifecycle): wait for Friendbot before funding accounts The Stellar RPC healthcheck passes before Friendbot is ready, causing 502 errors. Add a wait loop matching the pattern from e2e/setup.sh. --- lifecycle/ci-setup.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lifecycle/ci-setup.ts b/lifecycle/ci-setup.ts index 6dc1c3d..baed25c 100644 --- a/lifecycle/ci-setup.ts +++ b/lifecycle/ci-setup.ts @@ -29,10 +29,31 @@ async function fundAccount(publicKey: string): Promise { } } +async function waitForFriendbot(): Promise { + console.log("[ci-setup] Waiting for Friendbot..."); + for (let i = 0; i < 180; i++) { + try { + const res = await fetch( + `${FRIENDBOT_URL}?addr=GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF`, + ); + if (res.status === 200 || res.status === 400) { + console.log(" Friendbot is ready."); + return; + } + } catch { + // Not ready yet + } + await new Promise((r) => setTimeout(r, 1000)); + } + throw new Error("Friendbot did not become ready after 180s"); +} + async function main() { console.log("[ci-setup] Starting..."); const server = createServer(RPC_URL); + await waitForFriendbot(); + const admin = Keypair.random(); const provider = Keypair.random(); const treasury = Keypair.random();