flowfi icon indicating copy to clipboard operation
flowfi copied to clipboard

[SDK] Implement exponential backoff retry helper for Soroban RPC transaction status polling

Open blurbeast opened this issue 2 months ago • 9 comments

Overview

In packages/flowfi-sdk, polling for transaction inclusion via getTransaction can fail if Soroban RPC is experiencing momentary rate limits or network congestion.

Problem

  • A single network timeout causes client-side transaction submission to throw an error even though the transaction succeeded on-chain.

Proposed Changes

  1. Implement pollTransactionWithRetry with configurable exponential backoff (e.g. initial delay 1s, factor 1.5, max retries 5).
  2. Handle HTTP 429 and network disconnects gracefully.

Acceptance Criteria

  • [ ] Polling retries up to configured limit before failing.
  • [ ] Respects server Retry-After header if present.
  • [ ] Unit tests verify backoff timing and retry behavior.

blurbeast avatar Sep 27 '26 05:09 blurbeast

@iredis has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

Hi Maintainer, I’ve reviewed the issue and understand the requirements. I’m ready to work on it and deliver a clean solution.

ℹ️ Repo Maintainers: To accept this application, review their application or assign @iredis to this issue.

iredis avatar Sep 27 '26 07:09 iredis

@DevScoopee has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

I fully understand what needs to be done and can deliver. Kindly assign

ℹ️ Repo Maintainers: To accept this application, review their application or assign @DevScoopee to this issue.

DevScoopee avatar Sep 27 '26 07:09 DevScoopee

@longyi2 has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

I would like to work on this issue

ℹ️ Repo Maintainers: To accept this application, review their application or assign @longyi2 to this issue.

longyi2 avatar Sep 27 '26 07:09 longyi2

@David237-hub has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

Hello, I looked through the issue and the surrounding functionality to understand the problem properly. I can implement a clean solution and make sure it is properly tested.

ℹ️ Repo Maintainers: To accept this application, review their application or assign @David237-hub to this issue.

David237-hub avatar Sep 27 '26 07:09 David237-hub

@Cmitchelle7 has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

Hi Maintainer, reviewed the issue in detail. Full stack background with solid experience relevant to this task. No blockers on my end — I'm ready to submit a PR shortly. Please assign.

ℹ️ Repo Maintainers: To accept this application, review their application or assign @Cmitchelle7 to this issue.

Cmitchelle7 avatar Sep 27 '26 15:09 Cmitchelle7

Congratulations, @Cmitchelle7! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on September 30, 2026.

🧑‍💻 @Cmitchelle7: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

[!WARNING] When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

🌊 Happy Wave 🌊

drips-wave[bot] avatar Sep 27 '26 15:09 drips-wave[bot]

@K1NGD4VID — ready for review.

Summary: adds pollTransactionWithRetry and pollUntil to @flowfi/sdk — exponential backoff with Retry-After support for Soroban RPC status polling.

Two helpers rather than one, because the two real failure modes differ:

  • pollTransactionWithRetry — for the transport failing (429, 5xx, network). Retries thrown errors.
  • pollUntil — for { status: 'NOT_FOUND' } on a fresh hash, which rpc.Server.getTransaction returns as a normal response, not an error. Retries resolved-but-not-done results.

If you'd prefer one entry point with an option flag, that's a small change and I'll do it.

Verification locally: pnpm test in packages/flowfi-sdk — 41 passed (24 new + 17 pre-existing, zero regressions). Tests use an injected clock (sleep + random), so no real timers, no flakes.

Deliberately out of scope: wiring this into FlowFiClient.pollStreamIdFromTx. That method is documented as a stub pending contract ABI codegen (comment in client.ts). Once the ABI is pinned, the integration is a one-liner.

Cmitchelle7 avatar Sep 29 '26 10:09 Cmitchelle7

🎉 This issue has been marked as completed on GrantFox!

@Cmitchelle7's PR #1577 was approved and merged by @K1NGD4VID.

🏆 @Cmitchelle7: You earned 40 FoxPoints for this contribution! Your current tier: Builder (1,822 total points). Track your full progress on GrantFox.

👏 Great work, @Cmitchelle7! Keep contributing to LabsCrypt.

grantfox-oss[bot] avatar Oct 06 '26 07:10 grantfox-oss[bot]

This issue has been marked as completed by a Drips Wave moderator for @Cmitchelle7 as part of the Stellar Wave Program's 9th Wave 🥳

Moderator's reason: [Auto-assessed] The PR was accepted and merged by maintainer @K1NGD4VID (mergedAt 2026-10-06T07:05:26Z). The code cleanly implements pollTransactionWithRetry and pollUntil with comprehensive unit tests satisfying all acceptance criteria.

😎 @Cmitchelle7: You earned 200 Points for completing this issue! Once the Wave's rewards are finalized, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here.

🧑‍💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.

ℹ️ Note: This issue was marked complete via moderation. Points were issued even though the GitHub issue remains open.

drips-wave[bot] avatar Oct 11 '26 16:10 drips-wave[bot]