[BUG] useWallet() hook's returned disconnect function doesn't reset the hook's internal 'connecting' state if called while a connection attempt is still in flight

Open Beginner friendly
#1,001 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
66/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
typescript
Domain
backend

Research direction

Start in the hooks component and trace useWallet()'s connect() and returned disconnect() functions, focusing on how the in-flight promise updates the connecting flag. Reproduce the sequence in the issue and check the hook's existing tests, if present. Done when disconnecting during a pending connection prevents its later settlement from leaving connecting true.

Written by the indexing model from the issue text.

Description

bug difficulty: easy good first issue priority: medium sdk

Description

Calling the disconnect function returned by useWallet() while a connect() call it triggered is still pending leaves the hook's internal connecting flag stuck true, since the in-flight connect promise's eventual resolution/rejection still updates state after disconnect already ran.

Component

hooks

Steps to Reproduce

  1. Call the hook's connect().
  2. Immediately call disconnect() before the connection attempt resolves.
  3. Wait for the original connect attempt to settle.

Expected Behavior

Calling disconnect() mid-connection should cleanly cancel/ignore the in-flight connection attempt's eventual state update.

Actual Behavior

The hook's connecting flag can get stuck true indefinitely, breaking any UI relying on it to show/hide a loading spinner.

Environment

  • SDK version: 0.3.x
  • Node version: 20.x, 22.x
  • OS: macOS / Linux
  • Network: TESTNET

Code Example

const { connect, disconnect, connecting } = useWallet();

Error Output

N/A — no thrown error; behavior is incorrect but silent.

Difficulty

🟢 Easy

Additional Context

The in-flight connect promise's .then()/.catch() handlers aren't guarded against a disconnect having happened in the interim.

Dominant language
TypeScript
Stars
0
Forks
73
Avg merge
6h 26m
Merged PRs (30d)
37

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from trustflow-protocol/trustflow-sdk

All issues in trustflow-protocol/trustflow-sdk

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.