diff --git a/Docs/Tasks.md b/Docs/Tasks.md index fd09468..4c51bed 100644 --- a/Docs/Tasks.md +++ b/Docs/Tasks.md @@ -1,38 +1,3 @@ -### TASK-ABORT-01 — Missing `signal` Parameter on Multiple API Functions - -**Where found** -The following API functions accept no `signal` parameter and therefore cannot be cancelled regardless of what the calling hook does: - -| File | Function | -|------|----------| -| `frontend/src/api/history.ts` | `fetchHistory`, `fetchIpHistory` | -| `frontend/src/api/map.ts` | `fetchBansByCountry` | -| `frontend/src/api/jails.ts` | `fetchActiveBans`, `fetchJails` | -| `frontend/src/api/config.ts` | `fetchJailConfig`, `fetchInactiveJails`, `fetchJailConfigFiles`, `fetchFilterFiles` (partially — calls `fetchFilters` which accepts signal but discards it), `fetchActionFiles`, `fetchFilterFile`, `fetchActionFile` | -| `frontend/src/api/blocklist.ts` | `fetchImportLog`, `previewBlocklist` | - -**Goal** -Add an optional `signal?: AbortSignal` parameter to each function and forward it to the underlying `get()` call. Example: -```ts -export async function fetchHistory(query: HistoryQuery, signal?: AbortSignal): Promise { - return get(`${ENDPOINTS.history}?${buildQuery(query)}`, signal); -} -``` -Then update every calling hook to forward its controller's signal. - -**Possible traps and issues** -- `fetchFilterFiles` is an adapter that calls `fetchFilters()` internally. The correct fix is to accept `signal` and thread it into `fetchFilters(signal)`, then map the result. -- `previewBlocklist` is called from `useBlocklists.previewSource` which has no abort machinery. That hook should also be updated to add an `AbortController` if unmount cancellation is desired. -- Search for all call sites after adding the parameter; TypeScript's optional `?` means existing callers will not break but they should be updated to pass the signal where available. - -**Docs changes needed** -Add a coding convention to `Docs/Web-Development.md`: "All API functions that perform a `GET` request must accept an optional `signal?: AbortSignal` parameter and forward it to the HTTP client." - -**Why this is needed** -Without signals, navigating away from a page mid-fetch does not cancel the in-flight HTTP request. The response arrives, the callback fires, and React attempts a state update on an unmounted component. In development mode React warns about this; in production it causes silent no-ops and wastes server resources. - ---- - ### TASK-ABORT-02 — Hooks Create `AbortController` but Never Forward Signal to API **Where found**