-
Notifications
You must be signed in to change notification settings - Fork 27
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Minimal reproduction repo (required)
Not applicable - can reproduce directly in any project using the hook
Steps to reproduce
- Install @solana/client and @solana/react-hooks
- Create a component that uses useBalance with an invalid address:
const balance = useBalance("not-a-valid-address");
- Run the app
- App crashes with blank screen
Actual behavior
App crashes completely with uncaught error:
SolanaError: Expected base58-encoded address string of length in the range [32, 44]. Actual length: 19.
The error is not caught by the hook, causing React to crash and show a blank screen.
Expected behavior
The hook should handle invalid addresses gracefully by either:
- Returning an error state: { lamports: null, error: "Invalid address", fetching: false }
- Or returning null values without crashing
- Or validating input and logging a warning
The app should NOT crash from passing an invalid string to the hook.
Environment
- OS: macOS
- Node: v22.x
- Package versions: @solana/client@1.2.0, @solana/react-hooks@1.2.0
- Runtime: Chrome browser
- Cluster / endpoint: https://api.devnet.solana.com
Additional context
This is a DX issue because developers may pass user-typed addresses to this hook. Without input validation or error handling, there's no safe way to use this hook with untrusted input.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working