Skip to content

useXverse: early-exit async setup on effect cleanup #8

@satoshai-dev

Description

@satoshai-dev

Problem

In use-xverse.ts, the async setupXverse function awaits getXverseProductInfo() and request('wallet_connect') before registering the accountChange listener. If the effect cleans up while those are pending (e.g. deps change quickly), the work continues unnecessarily.

Fix

Add a cancelled flag that the cleanup sets to true. Check it after each await to bail out early, avoiding unnecessary SDK calls and listener registration.

Note: addListener is synchronous, so there's no actual listener leak — this is purely an early-exit optimization.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions