AOSSIE-Org / AOSSIE-Org/EduAid

[Enhancement]: Implement Request Cancellation and Timeout Handling for API Calls in eduaid_web

Aperta
#504 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
enhancement
Lingua principale
JavaScript
Stelle
171
Fork
425
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

### Feature and its Use Cases

## Feature: Request Cancellation & Timeout Handling for API Calls

### What is the feature?

Implement request cancellation and timeout control for frontend API calls using AbortController and configurable timeout logic.

Currently, API requests continue running even if:
- The user clicks the "Next" button multiple times
- The backend takes too long to respond
- The user navigates away during an ongoing request

This enhancement will ensure better control over in-flight network requests.

---

### How would users benefit from it?

- Prevents infinite loading state during backend delays
- Avoids duplicate question generation requests
- Improves responsiveness and perceived performance
- Ensures loading spinner always resets properly
- Provides a more production-ready user experience

---

### What scenarios would this feature address?

1. Backend model inference takes too long
2. User double-clicks the "Next" button
3. User changes page during active request
4. Network connection becomes unstable
5. Multiple API calls are triggered rapidly

By implementing cancellation and timeout logic, the UI remains stable and predictable.

### Additional Context

This enhancement will primarily affect:

- apiClient.js
- Text_Input.jsx
- Any other components consuming API endpoints

Proposed implementation:

- Use AbortController to cancel previous requests before starting new ones
- Add configurable timeout (e.g., 20 seconds)
- Ensure loading state resets on abort, timeout, or error
- Optionally disable "Next" button while request is active

I am willing to implement this enhancement.

### Code of Conduct

- [x] I have joined the [Discord server](https://discord.gg/hjUhu33uAn) and will post updates there
- [x] I have searched existing issues to avoid duplicates

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.