Skip to content

feat(frontend): improves error handling for btc wallet sync #5601

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

Merged

Conversation

BonomoAlessandro
Copy link
Collaborator

@BonomoAlessandro BonomoAlessandro commented Apr 3, 2025

Motivation

Currently every time the request to load the BTC wallet data fails, we display an error toast. In some cases this leads to multiple error toasts being displayed if the application has been idle. To improve the user experience we want to only show the error toast if the request fails 3 times in a row. In this way, the user will not be interrupted by unnecessary error messages when everything else works as expected.

Changes

  • improves error handling

@BonomoAlessandro BonomoAlessandro marked this pull request as ready for review April 3, 2025 12:26
@BonomoAlessandro BonomoAlessandro requested a review from a team as a code owner April 3, 2025 12:26
@DenysKarmazynDFINITY
Copy link
Contributor

I'm a bit concerned how would it look like in this case - let's imagine user has the BTC page open, and suddenly all the content is gone. Previously, the error implied that something went wrong (even though in a very unfriendly manner). But now, it will be gone without any feedback, and in the best case the data will reappear again in 30 seconds. IMO, it would be acceptable if we re-try to fetch the data instantly, without waiting for the next worker tick.

BonomoAlessandro and others added 3 commits April 3, 2025 14:57
…roves-btc-wallet-sync-error-handling

# Conflicts:
#	src/frontend/src/lib/constants/app.constants.ts
@peterpeterparker
Copy link
Member

Randomly landing here and unsolicited feedback: besides sharing @DenysKarmazynDFINITY's concern, I'm also worried about the implementation. If any logic related to handling potential errors from queries or updates needs to be implemented, it should be placed as close as possible to where those errors can occur otherwise, there's a risk of introducing issues as the all chain of events is not asserted. Additionally, implementing an error count in the UI for a message emitted from a worker feels a bit hacky but, that's more a personal opinion.

@BonomoAlessandro
Copy link
Collaborator Author

I updated the code so that the concern raised by @DenysKarmazynDFINITY is no longer valid. The current approach is to only reset the balancesStore and btcTransactionsStore if the data fetch fails three times in a row. This ensures that the shown data do not disappear without showing an error toast.
Additionally i have just asked prodsec if this would be a valid solution.

@peterpeterparker do you think it would be better to move the "counter logic" from the worker into the scheduler?

@peterpeterparker
Copy link
Member

would be better to move the "counter logic" from the worker into the scheduler?

I mean the logic is not in the worker. In the current proposed implementation, the counter is on the UI side, in the listener for messages.

I haven’t looked at the code, but IMO, the logic should be placed as close as possible to the source. If the error is triggered by the scheduler, then indeed yes, it should go there. Maybe it could even become a generic feature of the scheduler, notably if other features potentially require skipping a certain counts of errors, but of course, only if this pattern is actually what’s needed, and only if it’s acceptable from a security perspective.

@BonomoAlessandro
Copy link
Collaborator Author

As discussed here prod-sec allows us to do this changes.

BonomoAlessandro and others added 6 commits April 15, 2025 09:42
…roves-btc-wallet-sync-error-handling

# Conflicts:
#	src/frontend/src/btc/schedulers/btc-wallet.scheduler.ts
…roves-btc-wallet-sync-error-handling

# Conflicts:
#	src/frontend/src/tests/btc/workers/btc-wallet.worker.spec.ts
Copy link
Contributor

@DenysKarmazynDFINITY DenysKarmazynDFINITY left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small comment, otherwise LGTM!

@BonomoAlessandro BonomoAlessandro enabled auto-merge (squash) April 16, 2025 14:39
@BonomoAlessandro BonomoAlessandro merged commit 38a51cc into main Apr 16, 2025
28 checks passed
@BonomoAlessandro BonomoAlessandro deleted the feature(frontend)/improves-btc-wallet-sync-error-handling branch April 16, 2025 14:48
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.

4 participants