A background refresh between a Settings switch and its save can leave the old network's balance stored #653

Open
opened 2026-10-20 22:59:54 +02:00 by clawbot · 0 comments
Collaborator

Seen by the review of #648.

Where

A network switch in Settings (applyChainSwitchFields() then saveState() in the popup) against the background's balance refresh (backgroundRefresh() in src/background/index.js).

What happens

The popup clears every address's balance to "0" for the switch, then saves. If the background's refresh takes the lock between the clearing and that save, it reads the record, still on the old network, and writes the old network's balances into it, correctly for that moment. The popup's save then merges only the fields it changed since its last save. When the popup had last saved a balance of "0" for an address, the cleared "0" is not a change, so the background's old-network balance is kept, now under the new network.

What should happen

applyChainSwitchFields() clears the balances "so stale data from the previous chain is never displayed": after a switch, the stored record holds no balance from the previous network, whatever was saved before or in between.

Severity: minor

Definition of done

  • A switch's save leaves no balance from the previous network in the stored record, even when the background wrote one between the clearing and the save.
  • A test landing the background's write between the clearing and the save, failing on next.

Model: opus-5-5

Seen by the review of https://git.eeqj.de/sneak/AutistMask/pulls/648. ## Where A network switch in Settings (`applyChainSwitchFields()` then `saveState()` in the popup) against the background's balance refresh (`backgroundRefresh()` in `src/background/index.js`). ## What happens The popup clears every address's balance to "0" for the switch, then saves. If the background's refresh takes the lock between the clearing and that save, it reads the record, still on the old network, and writes the old network's balances into it, correctly for that moment. The popup's save then merges only the fields it changed since its last save. When the popup had last saved a balance of "0" for an address, the cleared "0" is not a change, so the background's old-network balance is kept, now under the new network. ## What should happen `applyChainSwitchFields()` clears the balances "so stale data from the previous chain is never displayed": after a switch, the stored record holds no balance from the previous network, whatever was saved before or in between. Severity: minor ## Definition of done - [ ] A switch's save leaves no balance from the previous network in the stored record, even when the background wrote one between the clearing and the save. - [ ] A test landing the background's write between the clearing and the save, failing on `next`. Model: opus-5-5
clawbot self-assigned this 2026-10-20 22:59:54 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/AutistMask#653