Skip to content

Commit

Permalink
Remove abort event listner for AbortController
Browse files Browse the repository at this point in the history
  • Loading branch information
Fonger committed Dec 5, 2023
1 parent 5eb3680 commit 43965f5
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/toolkit/src/createAsyncThunk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -600,14 +600,20 @@ export const createAsyncThunk = /* @__PURE__ */ (() => {
}
}

const abortedPromise = new Promise<never>((_, reject) =>
abortController.signal.addEventListener('abort', () =>
const abortedPromise = new Promise<never>((_, reject) => {
const abortHandler = () => {
reject({
name: 'AbortError',
message: abortReason || 'Aborted',
})
)
)
abortController.signal.removeEventListener(
'abort',
abortHandler
)
}

abortController.signal.addEventListener('abort', abortHandler)
})
dispatch(
pending(
requestId,
Expand Down

0 comments on commit 43965f5

Please sign in to comment.