You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
v2 introduces a regression in the silent-connect (now "neverAsk") flow.
// silently attempt to connect with a pre-authorized wallet
useEffect(() => {
// match the dapp with a wallet instance
connect({ modalMode: "neverAsk" }).then(wallet => {
// connect the dapp with the chosen wallet instance
wallet?.enable().then(() => {
const isConnected = !!wallet?.isConnected;
setIsConnected(isConnected);
});
});
}, []);
the code above works 100% of the time using v1.5, and it fails on v2.
I suspect a race because adding a timeout with delay=0 helps, i.e. -
// silently attempt to connect with a pre-authorized wallet
useEffect(() => {
setTimeout(() => {
// match the dapp with a wallet instance
connect({ modalMode: "neverAsk" }).then(wallet => {
// connect the dapp with the chosen wallet instance
wallet?.enable().then(() => {
const isConnected = !!wallet?.isConnected;
setIsConnected(isConnected);
});
});
}, 0); // <-- no real delay, just skip a cycle
}, []);
to reproduce, simply use the first version (without a timeout), choose a wallet, approve the connection (aka "pre-authorize"), then refresh the page. do it with a visible browser-inspect-application tab displayed, you'll see the id being removed (ptobably because getAvailableWallets returns empty array).
one more thing - if you adding a timeout, the code works, but you'll see multiple storage ids, meaning there are more races in there.
The text was updated successfully, but these errors were encountered:
it reproduces also on the new example app (though not 100%).
btw, another bug - I'm getting another wallet while having a last-wallet set (and pre-authorized/"enabled" in the wallet itself) in storage.
see both mentioned issues in these 2 videos -
fails to find starknet object on window object. Should I add some kind of wait, so that starknet object is injected in window object before get-starknet tries to read it?
v2 introduces a regression in the silent-connect (now "neverAsk") flow.
the code above works 100% of the time using v1.5, and it fails on v2.
I suspect a race because adding a timeout with delay=0 helps, i.e. -
to reproduce, simply use the first version (without a timeout), choose a wallet, approve the connection (aka "pre-authorize"), then refresh the page. do it with a visible browser-inspect-application tab displayed, you'll see the id being removed (ptobably because
getAvailableWallets
returns empty array).one more thing - if you adding a timeout, the code works, but you'll see multiple storage ids, meaning there are more races in there.
The text was updated successfully, but these errors were encountered: