Skip to content

PE-9132: Fetch Turbo free allowance concurrently during upload prep - #2169

Merged
vilenarios merged 1 commit into
devfrom
fix/concurrent-turbo-prep-fetch
Jul 27, 2026
Merged

PE-9132: Fetch Turbo free allowance concurrently during upload prep#2169
vilenarios merged 1 commit into
devfrom
fix/concurrent-turbo-prep-fetch

Conversation

@vilenarios

@vilenarios vilenarios commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #2166. getFreeAllowance() (the GET /v1/account/free call added there) was awaited late in each upload-preparation method, after the balance and cost round-trips that already run serially. But the allowance call is independent — it only needs the wallet address — so it added an extra sequential Turbo round-trip to every upload-modal open, and doubled the worst-case wait when payment.ardrive.io is unavailable (two back-to-back 8s ArDriveHTTP timeouts instead of one) before failing open to size-only behavior.

Change

Start the future up front in both getUploadPaymentInfoForEntities and getUploadPaymentInfoForUploadPlans, and await it where the free status is computed — so the allowance fetch overlaps the balance, size, and cost work already happening.

final freeAllowanceFuture = getFreeAllowance();  // starts immediately
turboBalance = await _getTurboBalance(...);       // runs concurrently
// ... sizes, cost estimates ...
final freeAllowance = await freeAllowanceFuture;  // already resolved

Timing only — no value changes. getFreeAllowance is a non-throwing wrapper (falls back to unknown), so the in-flight future can't become an unhandled rejection even if an intervening await throws.

Effect

Tests

Full suite unchanged — 733 pass. No behavioral assertions change (same calls, same values, same call counts).

🤖 Generated with Claude Code

https://claude.ai/code/session_01PsV2WFHZMGD9DUfX65cxuW

Summary by CodeRabbit

  • Performance Improvements
    • Improved upload payment evaluation by retrieving free-upload allowance information concurrently with other calculations.
    • Reduced potential waiting time when determining free upload status and payment details.

…oad prep PE-9132

getFreeAllowance() (added in #2166) was awaited late in each upload-prep
method, after the balance and cost round-trips that already run serially. The
allowance call is independent — it only needs the wallet — so it was adding an
extra sequential Turbo round-trip to every upload-modal open, and doubling the
worst-case wait when payment.ardrive.io is unavailable (two 8s timeouts back
to back instead of one) before it fails open.

Start the future up front in both getUploadPaymentInfoForEntities and
getUploadPaymentInfoForUploadPlans and await it where the free status is
computed, so it overlaps the balance, size and cost work. Timing only — no
value changes; getFreeAllowance is a non-throwing wrapper, so the in-flight
future cannot become an unhandled rejection. 733 tests unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PsV2WFHZMGD9DUfX65cxuW
@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a344959e-7b16-42c7-9ccb-a3112f863196

📥 Commits

Reviewing files that changed from the base of the PR and between 53d0b73 and 224bf97.

📒 Files selected for processing (1)
  • lib/core/upload/uploader.dart

📝 Walkthrough

Walkthrough

UploadPaymentEvaluator now starts free allowance retrieval before other asynchronous payment calculations in both supported upload payment paths, then awaits the in-flight result when determining free status.

Changes

Upload payment evaluation

Layer / File(s) Summary
Concurrent allowance retrieval
lib/core/upload/uploader.dart
Entity and upload-plan payment information methods start getFreeAllowance() concurrently with balance, cost, and size calculations, then use the completed future to compute freeStatus.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: fetching Turbo free allowance concurrently during upload preparation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/concurrent-turbo-prep-fetch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

Visit the preview URL for this PR (updated for commit 224bf97):

https://ardrive-web--pr2169-fix-concurrent-turbo-c6bnlv9k.web.app

(expires Mon, 03 Aug 2026 03:00:27 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: a224ebaee2f0939e7665e7630e7d3d6cd7d0f8b0

@vilenarios
vilenarios merged commit c4b7ffa into dev Jul 27, 2026
8 checks passed
@vilenarios
vilenarios deleted the fix/concurrent-turbo-prep-fetch branch July 27, 2026 13:05
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