AOSSIE-Org / AOSSIE-Org/EduAid

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

Abierto
#504 1 comentario 0 reacciones 0 asignados Ver en GitHub
enhancement
Lenguaje dominante
JavaScript
Estrellas
171
Forks
425
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.