equinor / equinor/fusion-framework
Consider aborting in-flight HTTP requests on unmount in useHttpClient
- Dominant language
- TypeScript
- Stars
- 10
- Forks
- 10
- Avg merge
- 19h 40m
- Merged PRs (30d)
- 150
Description
## Context
Both `useHttpClient` implementations create a memoized `HttpClient`/`IHttpClient` instance but never abort/dispose it when the owning component unmounts:
- [`packages/react/framework/src/hooks/use-http-client.ts`](https://github.com/equinor/fusion-framework/blob/main/packages/react/framework/src/hooks/use-http-client.ts)
- [`packages/react/modules/http/src/useHttpClient.ts`](https://github.com/equinor/fusion-framework/blob/main/packages/react/modules/http/src/useHttpClient.ts)
## Task
Investigate whether in-flight requests made through a client obtained via `useHttpClient` should be aborted when the consuming component unmounts (e.g. via an `AbortController` tied to a `useEffect` cleanup), to avoid state updates after unmount or wasted network calls.
## Acceptance criteria
- [ ] Decide whether abort-on-unmount is needed given how `HttpClient`/`IHttpClient` consumers typically use the returned client
- [ ] If needed, implement and cover with a test in both hooks; if not needed, remove the TODO comments
Contributor guide
Research direction
Start with packages/react/framework/src/hooks/use-http-client.ts and packages/react/modules/http/src/useHttpClient.ts, then inspect how HttpClient/IHttpClient consumers use the returned client and how the TODO comments relate to unmounting. Decide whether abort-on-unmount is appropriate; if so, add tests for both hooks, otherwise remove the TODO comments.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100