Skip to content

Can serializeError in AsyncThunkOptions be updated to be async (could be helpful for async calls like Response.text())? #3645

@TedGardner

Description

@TedGardner

I'd like to use that method to serialize incoming failed responses, but the responses might come in as a ResponseError - where getting the response body is an asynchronous operation.

In the meantime, I can continue using a try/catch in the payload creator. Alternatively, I could maybe be able to get around this by returning a SerializedError, then mutating it on Promise.then, but I'm really not sure if the latter is something I should consider.

Activity

changed the title [-]Can serializeError in AsyncThunkOptions be updated to be async (for async calls like Response.text() that might be helpful)?[/-] [+]Can serializeError in AsyncThunkOptions be updated to be async (could be helpful for async calls like Response.text())?[/+] on Aug 7, 2023
added this to the 1.9.x milestone on Aug 16, 2023
markerikson

markerikson commented on Aug 16, 2023

@markerikson
Collaborator

Possibly. Right now the call to serializeError() happens inside of the rejected() action prepare callback, which has to be sync. We could move that out to do the serialization call in the body of the thunk and make it async. But, this is low priority for us atm. If anyone wants to file a PR we can look at it.

modified the milestones: 1.9.x, 2.x bugfixes on Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @markerikson@aryaemami59@TedGardner

        Issue actions

          Can serializeError in AsyncThunkOptions be updated to be async (could be helpful for async calls like Response.text())? · Issue #3645 · reduxjs/redux-toolkit