Skip to content

RTKQ: Mutation gets stuck in 'Pending' despite rejection from the server. #1376

Closed
@aloysb

Description

@aloysb

Hi,

On multiple places, since I've updated our package the mutation is stuck on 'Pending' even when an error is thrown.

See screenshot and code below.
The server returns 422, but the mutation doesn't get rejected.

It works with fulfilled mutation, but not rejected ones.
I have the issue in multiple places in my codebase and had to revert back to handling the state manually.

Any clues?
Thank you!

// Mutation
  verifyEmail: builder.mutation({
      query: ({ key, email }) => ({
        url: `membership/validate-email/${key}/${email}`,
        method: "PUT",
      }),
      
 // In my component

   const [
    verifyEmailMutation,
    { isLoading, isError, isSuccess, isUninitialized },
  ] = useVerifyEmailMutation();
  
  <button onClick={() => { isUninitialized && verifyEmailMutation({ key, email }); } > Button </button>

Screen Shot 2021-08-03 at 10 59 28

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions