Skip to content

autoConnect only attempts once on page load; fails if wallet isn't ready yet (Petra) #709

@Yaron1902

Description

@Yaron1902

Hi team, we’re seeing frequent disconnects on refresh when using Petra.

Observed behavior

We use AptosWalletAdapterProvider with autoConnect={true}.
After refresh, useWallet().connected stays false and account is null.
This happens often in production; occasionally works locally.
We verified our app isn’t calling disconnect().
Root cause (suspected)
autoConnect only attempts once on initial load. If Petra isn’t injected/ready at that exact time (readyState !== Installed), the adapter gives up and never retries, so the session looks disconnected.

Repro steps

Connect Petra successfully.
Refresh the page.
Observe connected=false and account=null even though Petra becomes ready shortly after.
Expected

autoConnect should retry once the wallet becomes Installed, or
provide a built‑in retry/delay option.
Workaround we implemented
We added a manual retry (e.g., 1s delay) when wallet is not connected. This improves stability.

Would it be possible to add a retry mechanism or listen for wallet readiness changes before giving up?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions