A balance refresh in flight during a network switch writes the previous network's balances onto the new one #577

Open
opened 2026-10-19 02:51:19 +02:00 by clawbot · 0 comments
Collaborator

Seen by the review of #572, from reading the code.

Where

doRefreshAndRender() in src/popup/index.js and backgroundRefresh() in src/background/index.js. Each starts a balance refresh with the network's endpoints and wallets as they are, and when the requests return writes the balances into the same address records and saves.

What happens

A network switch (applyChainSwitchFields() in src/shared/chainSwitchFields.js) clears every address's balances while a refresh for the previous network may still be in flight. When that refresh returns, it writes the previous network's balances back onto the addresses, now shown under the new network, and records the refresh as done, so the next refresh on the new network waits its normal interval.

What should happen

applyChainSwitchFields() clears the balances on a switch "so stale data from the previous chain is never displayed". A refresh that returns after the network changed should be dropped, and the new network refreshed.

Severity: minor

Definition of done

  • A balance refresh started before a network switch writes nothing when it returns after the switch, in the popup and in the background.
  • A test holds a refresh open across a switch and checks the new network's addresses show no balance from the old one.

Model: opus-5-5

Seen by the review of https://git.eeqj.de/sneak/AutistMask/pulls/572, from reading the code. ## Where `doRefreshAndRender()` in `src/popup/index.js` and `backgroundRefresh()` in `src/background/index.js`. Each starts a balance refresh with the network's endpoints and wallets as they are, and when the requests return writes the balances into the same address records and saves. ## What happens A network switch (`applyChainSwitchFields()` in `src/shared/chainSwitchFields.js`) clears every address's balances while a refresh for the previous network may still be in flight. When that refresh returns, it writes the previous network's balances back onto the addresses, now shown under the new network, and records the refresh as done, so the next refresh on the new network waits its normal interval. ## What should happen `applyChainSwitchFields()` clears the balances on a switch "so stale data from the previous chain is never displayed". A refresh that returns after the network changed should be dropped, and the new network refreshed. Severity: minor ## Definition of done - [ ] A balance refresh started before a network switch writes nothing when it returns after the switch, in the popup and in the background. - [ ] A test holds a refresh open across a switch and checks the new network's addresses show no balance from the old one. Model: opus-5-5
clawbot self-assigned this 2026-10-19 02:51:19 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/AutistMask#577