Skip to content

Commit 3055fbb

Browse files
JulienKodemarkerikson
authored andcommitted
fix(2448): remove abort controller
1 parent c8f77a9 commit 3055fbb

File tree

1 file changed

+1
-33
lines changed

1 file changed

+1
-33
lines changed

packages/toolkit/src/createAsyncThunk.ts

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -553,36 +553,6 @@ export const createAsyncThunk = (() => {
553553
})
554554
)
555555

556-
let displayedWarning = false
557-
558-
const AC =
559-
typeof AbortController !== 'undefined'
560-
? AbortController
561-
: class implements AbortController {
562-
signal = {
563-
aborted: false,
564-
addEventListener() {},
565-
dispatchEvent() {
566-
return false
567-
},
568-
onabort() {},
569-
removeEventListener() {},
570-
reason: undefined,
571-
throwIfAborted() {},
572-
}
573-
abort() {
574-
if (process.env.NODE_ENV !== 'production') {
575-
if (!displayedWarning) {
576-
displayedWarning = true
577-
console.info(
578-
`This platform does not implement AbortController.
579-
If you want to use the AbortController to react to \`abort\` events, please consider importing a polyfill like 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only'.`
580-
)
581-
}
582-
}
583-
}
584-
}
585-
586556
function actionCreator(
587557
arg: ThunkArg
588558
): AsyncThunkAction<Returned, ThunkArg, ThunkApiConfig> {
@@ -591,10 +561,9 @@ If you want to use the AbortController to react to \`abort\` events, please cons
591561
? options.idGenerator(arg)
592562
: nanoid()
593563

594-
const abortController = new AC()
564+
const abortController = new AbortController()
595565
let abortReason: string | undefined
596566

597-
let started = false
598567
function abort(reason?: string) {
599568
abortReason = reason
600569
abortController.abort()
@@ -615,7 +584,6 @@ If you want to use the AbortController to react to \`abort\` events, please cons
615584
message: 'Aborted due to condition callback returning false.',
616585
}
617586
}
618-
started = true
619587

620588
const abortedPromise = new Promise<never>((_, reject) =>
621589
abortController.signal.addEventListener('abort', () =>

0 commit comments

Comments
 (0)