AOSSIE-Org / AOSSIE-Org/EduAid

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

未關閉
#504 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
enhancement
主要語言
JavaScript
星號
171
分支
425
PR 合併指標
30 天內沒有已合併 PR

描述

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

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。