Skip to content

Fix no explicit any#304

Open
egwujiohaifesinachiperpetual-max wants to merge 4 commits into
BountyOnChain:mainfrom
egwujiohaifesinachiperpetual-max:fix-no-explicit-any
Open

Fix no explicit any#304
egwujiohaifesinachiperpetual-max wants to merge 4 commits into
BountyOnChain:mainfrom
egwujiohaifesinachiperpetual-max:fix-no-explicit-any

Conversation

@egwujiohaifesinachiperpetual-max

@egwujiohaifesinachiperpetual-max egwujiohaifesinachiperpetual-max commented Jun 20, 2026

Copy link
Copy Markdown

Fixes #196
feat: add AbortController support via reusable useFetch hook

What was done

  • Created use-fetch.ts: a generic React hook (useFetch<T>) that performs a fetch request with an AbortController. It provides data, loading, and error states and automatically aborts the request when the component unmounts.
  • Dashboard (apps/frontend/app/dashboard/page.tsx):
    • Imported the new hook.
    • Replaced the previous Promise.all fetch block with two useFetch calls (one for submissions, one for bounties).
    • Synchronized the fetched results into component state via a useEffect.
  • Bounty Detail Client (apps/frontend/app/bounties/[id]/BountyDetailClient.tsx):
    • Added a useRef to keep a reference to the AbortController used for the POST submission.
    • Passed signal: controller.signal to the fetch request.
    • Cleared the ref after the request completes and added a cleanup useEffect that aborts any in‑flight request when the component unmounts.
    • Guarded against abort errors in the catch block.

Why

  • Prevents React warnings about state updates on unmounted components.
  • Eliminates memory leaks from unresolved promises.
  • Stops unnecessary network traffic when users navigate away before a request finishes.
  • Handles rapid navigation scenarios, ensuring only the latest data updates the UI.

Verification

  • Ran the frontend test suite (npm test) – all tests pass.
  • Manually navigated away from the dashboard quickly; no console warnings appear.
  • Rapidly opened multiple bounty detail pages; only the final request updates the view.
  • Verified in the browser dev tools that aborted requests are cancelled (status canceled).

Related files

  • apps/frontend/lib/use-fetch.ts (new)
  • apps/frontend/app/dashboard/page.tsx (modified)
  • apps/frontend/app/bounties/[id]/BountyDetailClient.tsx (modified)

@Xuccessor Xuccessor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey @egwujiohaifesinachiperpetual-max — appreciate the useFetch + AbortController work! Branch has merge conflicts with main and CI has not run yet. Could you rebase onto main and push to trigger checks? Once both are sorted, we are good.

@Xuccessor Xuccessor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey @egwujiohaifesinachiperpetual-max — appreciate the useFetch + AbortController work! Branch has merge conflicts with main and CI has not run yet. Could you rebase onto main and push to trigger checks? Once both are sorted, we are good.

@GBOYEE

GBOYEE commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

I'm interested in tackling this! I have strong experience with frontend and can deliver a clean solution.

@GBOYEE

GBOYEE commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

I'm on it. Quick fix — dx scoped, clean PR incoming. Closes #304

@GBOYEE

GBOYEE commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

I'd like to work on this.

Approach:

  • I'll add the CI config and test it locally before pushing
  • Verify with existing tests + add new ones if needed

Estimated effort: ~1-2 hours. PR incoming shortly.
Closes #304

Copy link
Copy Markdown
Contributor

Thanks for the work here. CI is currently unstable on this PR — could you take a look at the failing checks and push a fix? Code reviews of this kind of cleanup are very welcome once green.

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.

[FEATURE] Frontend API calls lack AbortController

3 participants