Redux Toolkit 2.0 createAsyncThunk abort signal: Should loading state reset automatically?
29K reputation · 01 May 2023, 02:15 UTC
When using Redux Toolkit 2.0's createAsyncThunk with an AbortSignal, the thrown AbortError is transformed into a rejected action whose error.message is set to "Aborted". The library does not automatically reset loading flags or other UI state tied to the request, leaving it to developers to dispatch a separate cleanup action or to interpret the rejected action's metadata.
This design choice creates variability across codebases: some teams manually clear state in a reducer, others rely on the rejected action, and a few forget to handle aborts altogether. The unresolved question is whether a future version should provide a built‑in helper (e.g., an abortReducer) that automatically clears loading state on abort, or retain the manual approach to preserve flexibility for custom side‑effects and middleware.
Should Redux Toolkit ship an automatic loading‑state reset for aborted thunks? What impact would such a helper have on existing reducers, middleware chains, and upgrade paths? How could the library version the change to avoid breaking current implementations that depend on the current manual handling?