fix(web): a tab that changes identity doesn't tell the others, which keep writing the previous identity's data
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start by reading rust/src/ around IndexedDbStorage::clear_identity_data in indexeddb.rs:505, then trace the mentioned save_trade and patch_trade_by_order_id paths and where resetIdentityScopedState runs. The issue leaves cross-tab coordination open, so first compare the proposed approaches and identify the relevant entry points. Done means a two-tab manual check confirms that after an identity change, the other tab cannot write rows for the previous identity.
Written by the indexing model from the issue text.
Description
Summary
On web every tab of the origin shares one IndexedDB database, but each tab runs its own Rust core with its own in-memory identity. When one tab replaces the identity (generate or import → delete_identity), it wipes the shared stores (IndexedDbStorage::clear_identity_data, indexeddb.rs:505), but the other tabs are never told. They keep:
- the previous identity and its trade keys in memory,
- their relay subscriptions to that identity's trades and daemon messages,
- their Dart caches (
resetIdentityScopedStateonly runs in the tab that did the wipe).
So the next daemon message one of them handles writes through save_trade / patch_trade_by_order_id, and the previous identity's trade reappears in the new identity's database. Unlike #554, this needs no race: it happens whenever a second tab is open and receives anything.
This breaks the "a new identity starts from zero" rule (#533) on web.
From reading the code, not reproduced yet: I found no cross-tab coordination (BroadcastChannel, storage events, a leader Web Lock) in rust/src/ or lib/.
Steps to reproduce (expected)
-
Open the web app in two tabs with an identity that has an active trade.
-
In tab A, generate a new user.
-
Trigger a daemon message for that trade (or just wait for a reconnect replay) while tab B stays open.
-
In tab A, check My Trades / IndexedDB
trades: the old trade is back. -
Broadcast the change. The wiping tab posts on a
BroadcastChannel; the others drop their state and reload (or show "identity changed in another tab" and reload on tap). Smallest change; tabs stay usable. -
One active tab. A leader Web Lock: only the tab holding it runs the core; the others show "open in another tab". Also removes the other multi-tab write hazards, but changes UX.
Either way the wipe should also take the store locks (#554) so the same-tab case is closed too.
Acceptance
- After an identity change in one tab, no other tab writes rows of the previous identity.
- Verified by hand with two tabs (the repo has no wasm test suite yet, see #409).
Related: #554, #533, #408.
- Dominant language
- Dart
- Stars
- 11
- Forks
- 9
- Avg merge
- 20h 36m
- Merged PRs (30d)
- 236
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from MostroP2P/app
-
area: ui feature priority: medium
Difficulty 1/5 Under an hour Newbie friendliness 90/100
Maintainers usually reply within 1 day
-
area: rust-core bug priority: low
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
area: ui
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
AimesSoft/NipaPlay-Reload#1022 ·
Maintainers usually reply within 1 day
-
`jwtPayload.roomConfiguration` returns null fields for tokens from LiveKit server SDKsPossibly taken @RaphaelFakhri claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
livekit/client-sdk-flutter#1243 ·
Maintainers usually reply within 1 day
-
bug to check
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
zjs81/meshcore-open#602 · 3 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
MunichWays/munich-ways-app#275 ·
Maintainers usually reply within 1 day