Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT][AsyncThunk] Pass abort reason of thunk action to AbortController #2395 #2420

Closed

Conversation

FaberVitale
Copy link
Contributor

Closes #2395

Description

asyncThunkApi.signal.reason is set to the first value provided to asyncThunkHandle.abort.

Other changes

  • fixes signal.aborted not being set to true in the AbortController shim if abort is called.

Implementation details

It uses a utility function abortControllerWithReason, already used within the listenerMiddleware, that patches reason if it is not available.

…vided to asyncThunkHandle.abort reduxjs#2395

Other changes:

fixes signal.aborted not set in AbortController shim
@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit b72d7f5:

Sandbox Source
Vanilla Configuration
Vanilla Typescript Configuration
rsk-github-issues-example Configuration
@examples-query-react/basic Configuration
reduxjs/redux-toolkit Configuration
@examples-action-listener/counter Configuration

@phryneas
Copy link
Member

To be honest, I'm not really sure if I like the thought of adding more "polyfill-like" code. Actually, I'd like to remove the AbortController polyfill in general with RTK 2.0 (#2448).

So I guess we'd need a bit research first:

  • At that point, what platforms do have AbortController, but not reason?
  • As these platforms will need a Polyfill anyways, which of the existing polyfills do not have reason?
  • If all platforms that have it natively support reason, wouldn't it make more sense to just PR into the missing polyfills?

@FaberVitale
Copy link
Contributor Author

Why should these changes be included in a minor release (1.9)?

  1. fix signal.aborted not being set to true in the polyfill that causes inconsistent behavior between runtimes.
  2. Add support to signal.reason reusing code that is already part of listenerMiddleware logic.

what platforms do have AbortController, but not reason?

signal.reason support | 2022-06-25

abortSignal.reason is available in:

server runtimes

browsers

Samsung internet is a relevant mobile browser (especially in Germany) that does not support signal.reason.

createAsyncThunk changes for 2.0.0

I agree that we should remove if possible obsolete polyfills in 2.0.

@markerikson markerikson deleted the branch reduxjs:v1.9-integration November 4, 2022 14:06
@markerikson markerikson closed this Nov 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants