Issue with aborting createAsyncThunk
See original GitHub issueHey everyone, I’ve been using RTK for a while now with no real issues and love where the library is going. Recently I ran into my first need to actually abort a call and tried following the docs however I ended up getting an runtime error saying that
Uncaught TypeError: promise.abort is not a function
. I’m on version 1.5.0.
I’m not sure what i could be doing wrong as my code looks like this and follows the tutorial.
const promise = dispatch(
asnycThunkCall({
productId: "id",
}),
);
return () => {
promise.abort();
};
My dispatch is also setup like
export type AppDispatch = typeof store.dispatch;
export const useAppDispatch = () => useDispatch<AppDispatch>();
I tried printing out the promise returned from the dispatch and I didn’t see an abort function but I don’t know how reliable that is. Any tips?
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (1 by maintainers)
Top Results From Across the Web
redux toolkit - Abort is not working for createasyncthunk in react
How to abort the Action Abort is not working for createasyncthunk in react. How can I abort any action of createAsyncThunk?
Read more >How do i cancel a createAsyncThunk action which calls an api?
Calling thatPromise.abort() will at least cancel dispatching actions, but doesn't do anything to cancel the actual request by itself. However, ...
Read more >10 - Canceling thunks while running - redux toolkit - YouTube
In this series, we'll be going through the createEntityAdapter API and use it with createAsyncThunk playlist: In this series, we'll be going ...
Read more >reduxjs/toolkit - NPM Package Overview - Socket.dev
This bugfix release fixes assorted issues that were reported with RTK ... Calling promise.abort() on a createAsyncThunk promise before an ...
Read more >createAsyncThunk.ts - UNPKG - @reduxjs/toolkit
@reduxjs/toolkit/src/createAsyncThunk.ts ... @ts-ignore we need the import of these types due to a bundling issue. ... 164, abort(reason?: string): void.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@msutkowski Hmm let me try that. You are correct that I couldn’t recreate in the CSB. It worked on there with the same setup. So something must be off with my versions or modules. Thanks let me try that.
That’s fair. I did your above changes and things are working now as expected. I’ll play around more to see if I can better fine tune it. Thanks again for the help I really appreciate it!