Skip to content

Fix delayed swap info refresh on progress events - #1183

Merged
binarybaron merged 1 commit into
eigenwallet:masterfrom
lh-0610:fix/swap-info-refresh
Aug 3, 2026
Merged

Fix delayed swap info refresh on progress events#1183
binarybaron merged 1 commit into
eigenwallet:masterfrom
lh-0610:fix/swap-info-refresh

Conversation

@lh-0610

@lh-0610 lh-0610 commented Aug 1, 2026

Copy link
Copy Markdown

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

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
@binarybaron

Copy link
Copy Markdown

LGTM!

@binarybaron
binarybaron merged commit b0174c5 into eigenwallet:master Aug 3, 2026
@lh-0610

lh-0610 commented Aug 3, 2026

Copy link
Copy Markdown
Author

Thank you for reviewing and merging the PR!

My Monero address for the 0.1 XMR bounty is:

44cr7E1RS3YgyTXmmTPj2UPUdKvKZAvw5LoNeaDEQUDq893e6aLVtCUPv2XEWs9kKjd5E3N7sRtFuREpo5e3YNkzMAhiwVX

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.

[0.1 XMR] Swaps take too long to show up

2 participants