Fix RefCell borrow panic during async gateway operations #7
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
When navigating the app while logged in, a
RefCell already mutably borrowedpanic occurs atcrates/frontend/src/main.rs:356:25. This happens because render-time code callsborrow()on theRc<RefCell<HeroLedgerClient>>while an async gateway operation holdsborrow_mut()viatake_gw().Root Cause
Dioxus re-renders components while futures are suspended at
.awaitpoints. Theaccount_id_string()method onHandleExtcallsself.borrow()during render, conflicting withtake_gw()which callsborrow_mut()during async I/O.Affected components:
ActIdentity(main.rs)PreparePreRegister(prepare_pre_register.rs)NodeLookup(nodes.rs)Solution
Introduce a
Signal<GatewayAccountId>that is set once when gateway credentials are established. All render-time code reads from this signal instead of borrowing the RefCell. The RefCell is then only ever accessed by async code via the existingtake_gw/put_gwpattern.Also clean up compiler warnings (unused import in
async_yield, dead code onvault_list_with_keys).