Skip to content

fix(backend): tolerate Soroban RPC ingestion lag in playground#36

Merged
miguelnietoa merged 2 commits into
feat/landing-account-analyzefrom
fix/playground-rpc-lag
Jun 29, 2026
Merged

fix(backend): tolerate Soroban RPC ingestion lag in playground#36
miguelnietoa merged 2 commits into
feat/landing-account-analyzefrom
fix/playground-rpc-lag

Conversation

@miguelnietoa

Copy link
Copy Markdown
Member

Problem

The playground died right after "Demo account funded" with "The transaction was rejected by the network" (502), and sometimes with a gateway timeout (504).

Root cause is Soroban RPC ingestion lag, not the transactions:

  • The session route funds the demo account via Friendbot (confirmed through Horizon), then the SETUP mess step immediately reads it back with server.getAccount() over the Soroban RPC — a separate node whose ledger ingestion lags a few seconds. It throws Account not found → 502 → UI shows "rejected by the network".
  • The same lag makes slow confirmations exceed the route's maxDuration = 60, while the confirmation poll budget is 90s (POLL_MAX_ATTEMPTS × POLL_INTERVAL_MS) → 504 FUNCTION_INVOCATION_TIMEOUT.

The rest of the codebase already reads account state from Horizon precisely because "Horizon returns all of that ... with zero indexing lag for newly created accounts" (account-live.ts); the playground was the one path still hitting the lag-prone RPC getAccount.

Changes

  • buildSignSubmit retries getAccount with a bounded backoff (ACCOUNT_VISIBILITY_*), treating account not found as transient and surfacing any other error immediately
  • raise the mess route maxDuration to 120s to cover the retry plus the full 90s confirmation poll
  • unit tests reproducing the not-found-then-visible race
  • (unrelated, also fixed here) bun type-check was failing on pre-existing cache: "no-store" fetch calls because the app tsconfig auto-included @types/bun. Scope the app config to types: ["node"] and give the tests config the dom lib.

Verification

  • bun type-check ✅ · bun lint ✅ · bun test tests/unit ✅ (230 pass)
  • Reproduced end-to-end against testnet: SETUP previously failed with 502 Account not found; with the fix all mess steps return 200 and the playground reaches the demolish-ready state with real on-chain txs

The playground funds the demo account via Friendbot (confirmed through
Horizon), then the SETUP mess step immediately reads it back over the
Soroban RPC. That RPC is a separate node whose ledger ingestion lags a
few seconds behind, so getAccount throws "Account not found" and the
step fails with a 502 the UI surfaces as "rejected by the network".
Slow confirmations hit the same lag and exceeded the 60s function limit
while the poll budget is 90s, producing 504s.

- wrap getAccount in buildSignSubmit with a bounded retry that treats
  "account not found" as transient and surfaces any other error at once
- raise the mess route maxDuration to 120s so it covers the retry plus
  the full 90s confirmation poll
- add unit tests reproducing the not-found-then-visible race
The app tsconfig set no `types`, so tsc auto-included @types/bun and its
fetch overload, whose RequestInit lacks the web `cache` option used in
the Horizon reads (account-live.ts, horizon-adapter.ts) - breaking
`bun type-check`. The tests config (types: ["bun"]) hit the same wall on
those files via transitive imports.

- scope the app tsconfig to `types: ["node"]` so app code is checked
  against Node/DOM fetch (which has `cache`), not Bun's
- give the tests config the dom lib so transitively imported app fetch
  calls still resolve under bun:test
@vercel

vercel Bot commented Jun 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lumenwipe Ready Ready Preview, Comment Jun 29, 2026 5:58pm

@miguelnietoa miguelnietoa merged commit c970fb1 into feat/landing-account-analyze Jun 29, 2026
4 checks passed
@miguelnietoa miguelnietoa deleted the fix/playground-rpc-lag branch June 29, 2026 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant