AOSSIE-Org / AOSSIE-Org/EduAid

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

Đang mở
#504 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
enhancement
Ngôn ngữ chính
JavaScript
Star
171
Fork
425
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.