-
Notifications
You must be signed in to change notification settings - Fork 240
Activation deduplication and gating to prevent competing tasks #3304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
|
Visit the preview URL for this PR (updated for commit 6cd343a): https://walletrc--pull-3304-merge-0g310oev.web.app (expires Wed, 12 Nov 2025 05:20:43 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: f66a4ff03faa546f12f0ae5a841bd9eff2714dcc |
…g to prevent competing tasks (v0.9.3)
closes #3302
What changed (high level)
Introduced per-asset in-flight activation deduplication so only one activation runs per asset:
lib/bloc/coins_bloc/coins_repo.dart:_activationsInFlightmap and join-existing behavior insideactivateAssetsSync(...).Avoid over-eager activation retries that could spawn new backend tasks:
ConstraintError), wait for availability instead of starting a new task.Added an initial-activation gate and wired it through the app to prevent early auto-activations from UI flows:
CoinsRepo:markInitialActivationStart(),markInitialActivationComplete(),waitForInitialActivationToComplete(timeout: 30s)CoinsBloc: marks start/end of initial activation to drive the gate.lib/views/dex/dex_helpers.dart(Swap helper): waits for gate before activating.lib/bloc/market_maker_bot/market_maker_trade_form/market_maker_trade_form_bloc.dart: waits for gate in_autoActivateCoin.lib/bloc/bridge_form/bridge_bloc.dart: awaits_autoActivateCoinin_onSetSellCoin.lib/bloc/fiat/fiat_onramp_form/fiat_form_bloc.dart: waits for gate beforeactivateAssetsSync.Prevent pre-activation balance calls from spawning backend tasks:
CoinsRepo.tryGetBalanceInfo(...)returns zero if asset is not active (no SDK balance RPC).getBalanceonly when the coin is active; otherwise uses zero.Files touched (key lines)
lib/bloc/coins_bloc/coins_repo.dart: in-flight dedup, initial activation gate, idempotent error handling, guardedtryGetBalanceInfo.lib/bloc/coins_bloc/coins_bloc.dart: callsmarkInitialActivationStart/Complete.lib/views/dex/dex_helpers.dart: gate wait before activation (30s timeout).lib/bloc/market_maker_bot/market_maker_trade_form/market_maker_trade_form_bloc.dart: gate wait and guarded balance reads.lib/bloc/bridge_form/bridge_bloc.dart: await_autoActivateCoinon sell coin set.lib/bloc/fiat/fiat_onramp_form/fiat_form_bloc.dart: gate wait before activation.Why this matters
These changes eliminate most duplicate activation attempts and the cascading IndexedDB uniqueness errors that were caused by competing tasks when entering Swap before initial activation completed (see issue #3302). Remaining rare duplication observed for BTC-segwit is traced to SDK behavior and will be addressed there.
Reference: Premature Swap page entry prompts competing activations #3302
QA: Quick test plan
Prereqs:
ConstraintErrorlogs.RequestingWalletBalancetasks initiated by the form; balance should be treated as 0 until active._onSetSellCoinawaits_autoActivateCoin; activation finishes then fees/volumes are fetched.Notes for reviewers