Skip to content

fix(cross-chain-accounts): add error handling for blob fetching in AccountBlobs - #38

Open
Baophan00 wants to merge 1 commit into
shelby:mainfrom
Baophan00:fix/account-blobs-error-handling
Open

Baophan00 wants to merge 1 commit into
shelby:mainfrom
Baophan00:fix/account-blobs-error-handling

Conversation

@Baophan00

@Baophan00 Baophan00 commented Sep 14, 2026

Copy link
Copy Markdown

Summary

The AccountBlobs component had no error handling for the getAccountBlobs API call. If the API failed, the promise rejection was unhandled and the user saw no feedback — just an empty state. This adds proper try/catch, loading state, and cleanup on unmount.

Closes shelby/feedback#45

Problem

In apps/cross-chain-accounts/components/AccountBlobs.tsx:

  • The useEffect had an async function that returned a value but was called with .then() — if the API rejected, it became an unhandled promise rejection.
  • No loading state — user didn't know if data was loading or empty.
  • No error state — API failures silently showed "No blobs found".
  • No cleanup on unmount — potential state update after component unmounts.

Solution

  • Convert the inner async function to use try/catch and set error state explicitly.
  • Add isLoading state for UI feedback during fetch.
  • Add cleanup function (cancelled flag) to prevent state updates after unmount.
  • Update render to show loading and error states with appropriate messages.

Files changed

  • apps/cross-chain-accounts/components/AccountBlobs.tsx — 39 additions, 10 deletions

Test plan

  • Simulate API failure (e.g., invalid API key) → error message shown
  • Successful fetch → blobs displayed normally
  • Switch account while fetching → old fetch doesn't set state
  • Normal loading → "Loading blobs..." shown

🤖 Generated with Hermes Agent (Nous Research)


Note

Low Risk
Localized UI and async lifecycle changes in one component; no auth, payments, or shared API contract changes.

Overview
AccountBlobs now handles blob list fetches with explicit loading, error, and empty UI instead of treating failures like “no blobs.”

The useEffect fetch uses try/catch/finally, sets isLoading/error, clears error when the wallet disconnects, and uses a cancelled cleanup so in-flight requests don’t update state after unmount or account/refreshTrigger changes. Successful loads still populate the existing blob grid unchanged.

Reviewed by Cursor Bugbot for commit 6399d11. Bugbot is set up for automated code reviews on this repo. Configure here.

…hing

The async getAccountBlobs call had no error handling — if the API
failed, the promise rejection was unhandled and the user saw no
feedback. This adds:
- try/catch around the API call with error state
- Loading state while fetching
- Cleanup on unmount to avoid state updates after cancellation
- Proper error message display in the UI

Co-Authored-By: Hermes Agent <noreply@nousresearch.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 6399d11. Configure here.

return;
}
const getBlobs = async (): Promise<BlobMetadata[]> => {
const blobs = await getShelbyClient().coordination.getAccountBlobs({

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty state flashes before loading

Low Severity

isLoading starts as false and is left unchanged when account is missing, so the first paint after a wallet connect has no loading flag, no error, and empty blobs. The empty-state copy is shown until useEffect later sets isLoading. With autoConnect this flicker happens on page load and again on every reconnect.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 6399d11. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug]: Multiple 401 Unauthorized errors on GraphQL and TypeError in popup.js

1 participant