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

checkError can have undefined error as parameter #9845

Open
sebastianbuechler opened this issue May 14, 2024 · 1 comment
Open

checkError can have undefined error as parameter #9845

sebastianbuechler opened this issue May 14, 2024 · 1 comment

Comments

@sebastianbuechler
Copy link
Contributor

Since a couple weeks we get the behavior that if we access the root address of our react-admin application it gets stuck on loading because in the AuthProvider a new behavior appeared: the checkError method can have an undefined error as input parameter.

According to the docs this is not intended as shown in the example implementation: https://marmelab.com/react-admin/AuthProviderWriting.html

Was there a change on how the AuthProvider checkError is being used?

Steps to reproduce:
Use the example AuthProvider implementation and call the root address.

This fixes the problem, but it feels a bit weird.

  checkError: (error) => {
    if (!error) {
      return Promise.resolve();
    }

    const status = error.status;
    // Revoke access_token if status in unauthorized
    if (status === 401 || status === 403) {
      OIDCUserManager.revokeAccessToken();
      return Promise.reject({
        message: "Authentication error. Please login again.",
      });
    }
    return Promise.resolve();
  },

Additionally, there seems to be a related issue on some internal code called Retryer where the onError function also acts on an undefined error input parameter as well as the useQuery call with the auth/getPermissions key wants to act on an undefined error while handling it in the onError method.

image

image

Environment

  • React-admin version: 4.16.17
  • Last version that did not exhibit the issue (if applicable): Not sure, however it did not appear a couple weeks ago.
@fzaninotto
Copy link
Member

Hi, and thanks for your report. We need a reproduction to investigate on this bug. Can you please tweak the simple example (link below) and post a link to your modified sandbox?

https://stackblitz.com/github/marmelab/react-admin/tree/master/examples/simple?file=README.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants