Skip to content

Deduplicate in-flight mutating requests and add rate-limit-aware error handling #44

Closed

Description

@chonilius

Problem

src/lib/api.ts#apiRequest (used for all user-triggered mutating actions: claim, fund, deposit) has no retry, no rate-limit awareness, and no request deduplication/in-flight tracking. Combined with the lack of visible disabled/pending states audit needed in IssueActions.tsx/MilestoneActions.tsx (see the interrupted-flow issue in this batch), there's a related but distinct risk: nothing prevents a user from rapidly re-clicking "claim" or "fund" before the first request resolves, generating multiple concurrent identical requests. If the backend applies rate limiting (a reasonable assumption for a financial-action API, whether or not it currently does), apiRequest's error handling treats a 429 identically to any other non-2xx error — surfacing whatever generic message the backend body provides with no special handling (no backoff-and-retry suggestion, no "you're doing that too fast, wait Ns" UI), and worse, if multiple concurrent duplicate requests are in flight and the backend isn't perfectly idempotent, they risk being processed as separate actions.

Why this is hard

  • Requires designing an in-flight request tracking/deduplication layer at the apiRequest/apiPost level (or at each call site) that's generically reusable across claim/fund/deposit/wallet-link actions rather than a one-off fix per component, since this is a systemic gap in the shared API client, not a single call site's bug.
  • Must distinguish, in the UI, between a request that's deduplicated client-side (silently ignore the duplicate click, no user-visible error) versus a genuine 429 from the backend (show a clear rate-limit message, ideally respecting a Retry-After header if the backend sends one — check whether apiRequest's current error handling even reads response headers at all, since it currently only reads res.text()/res.status).
  • Needs to correctly interact with the idempotency-key work from the interrupted-flow issue in this batch — deduplication and idempotency solve related but distinct problems (client-side accidental double-submit vs. server-confirmed exactly-once execution across retries) and the design here should compose with, not duplicate, that work.
  • Button/CTA-level disabled states need auditing across every mutating action's UI (IssueActions.tsx, MilestoneActions.tsx, the wallet connect button, any settings/profile mutation) to confirm they're actually disabled during an in-flight request, not just "usually is because the developer remembered" — this requires reading each component, not assuming.

Scope

  • Add in-flight request deduplication to apiRequest/apiPost (or a wrapping layer) keyed by request signature, silently coalescing duplicate rapid-fire submissions.
  • Add Retry-After-aware 429 handling with a clear, distinct UI message from other error types, in ApiRequestError and its consumers.
  • Audit every mutating-action UI (claim, fund, deposit, wallet link, and any others found) for correct disabled-during-pending state; fix any that are missing it.
  • Add tests simulating rapid double-clicks and simulated 429 responses.

Acceptance criteria

  • Rapidly clicking a claim/fund/deposit CTA multiple times results in exactly one network request being sent (or clearly coalesced), verified via network call count.
  • A simulated 429 response shows a distinct, actionable rate-limit message, honoring Retry-After if present.

Activity

  1. added
    very hard
    performance
    bug
    on Jul 15, 2026
  2. added
    GrantFox OSS
    Maybe Rewarded
    Official Campaign | FWC26
    on Jul 15, 2026
  3. added
    Stellar Wave
    on Aug 25, 2026
  4. tilljack60-cmd commented on Aug 25, 2026

    @tilljack60-cmd

    @tilljack60-cmd has applied to work on this issue as part of the Stellar Wave Program's 8th wave.

    i will like to work on this issues

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

  5. oldtaker24 commented on Aug 25, 2026

    @oldtaker24
    Contributor

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

    i will like to work on this issues

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

  6. drips-wave commented on Aug 25, 2026

    @drips-wave

    Congratulations, @oldtaker24! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on August 31, 2026.

    🧑‍💻 @oldtaker24: 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 🌊

  7. drips-wave commented on Aug 25, 2026

    @drips-wave

    This issue has been completed by @oldtaker24 as part of the Stellar Wave Program's 8th Wave 🥳

    😎 @oldtaker24: You earned 200 Points for completing this issue! After the current Wave ends, 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. You can also Leave a review to share your experience working on this issue.

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

  8. removed
    Stellar Wave
    on Oct 15, 2026
  9. added
    Stellar Wave
    on Oct 15, 2026
  10. removed
    Stellar Wave
    on Oct 15, 2026
  11. added
    Stellar Wave
    on Oct 15, 2026
  12. removed
    Stellar Wave
    on Oct 15, 2026
  13. added
    Stellar Wave
    on Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

GrantFox OSSMaybe RewardedOfficial Campaign | FWC26Stellar Wavebugperformancevery hard

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions