AOSSIE-Org / AOSSIE-Org/EduAid

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

Ouverte
#504 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub
enhancement
Langage dominant
JavaScript
Étoiles
171
Forks
425
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

### 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

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.