Fix delayed swap info refresh on progress events - #1183
Merged
Conversation
The swap info refresher wrapped a 3s debounce inside a 2s throttle. The throttle released a call every 2s and each release reset the debounce timer. Because 2s < 3s the timer never expired while progress events kept arriving, so the GUI stopped refreshing for as long as the swap kept making progress. A single isolated event still waited 3s, and after the last event of a burst the refresh took up to 5s: up to 2s for the throttle trailing edge plus the 3s debounce window. Drop the inner debounce and keep only the 2s throttle with its existing leading and trailing edges. The first event now refreshes immediately, rapid events coalesce, a continuous stream refreshes every 2s, and the final event is not lost. The throttle layer is unchanged, so no refresh can land later than it did before. The throttle stays to rate limit the backend: each refresh issues both getSwapInfo and getSwapTimelock. Extract the factory into swapInfoUpdater.ts. storeListener.ts pulls in the whole Tauri RPC and Redux graph, which cannot be imported into a unit test without heavy mocking. Add three tests: the first event refreshes immediately, rapid events collapse into one leading plus one trailing refresh, and a continuous event stream keeps refreshing instead of stalling. The last one is the regression test for this bug. Closes eigenwallet#822
|
LGTM! |
Author
|
Thank you for reviewing and merging the PR! My Monero address for the 0.1 XMR bounty is: 44cr7E1RS3YgyTXmmTPj2UPUdKvKZAvw5LoNeaDEQUDq893e6aLVtCUPv2XEWs9kKjd5E3N7sRtFuREpo5e3YNkzMAhiwVX |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The swap info refresher wrapped a 3s debounce inside a 2s throttle. The throttle released a call every 2s and each release reset the debounce timer. Because 2s < 3s the timer never expired while progress events kept arriving, so the GUI stopped refreshing for as long as the swap kept making progress.
A single isolated event still waited 3s, and after the last event of a burst the refresh took up to 5s: up to 2s for the throttle trailing edge plus the 3s debounce window.
Drop the inner debounce and keep only the 2s throttle with its existing leading and trailing edges. The first event now refreshes immediately, rapid events coalesce, a continuous stream refreshes every 2s, and the final event is not lost. The throttle layer is unchanged, so no refresh can land later than it did before.
The throttle stays to rate limit the backend: each refresh issues both getSwapInfo and getSwapTimelock.
Extract the factory into swapInfoUpdater.ts. storeListener.ts pulls in the whole Tauri RPC and Redux graph, which cannot be imported into a unit test without heavy mocking.
Add three tests: the first event refreshes immediately, rapid events collapse into one leading plus one trailing refresh, and a continuous event stream keeps refreshing instead of stalling. The last one is the regression test for this bug.
AI usage disclosure
GPT-5.6-sol-high was used for code analysis, while Claude-opus-5 was used for code review and testing.
Closes #822