react-admin icon indicating copy to clipboard operation
react-admin copied to clipboard

checkError can have undefined error as parameter

Open sebastianbuechler opened this issue 1 year ago • 1 comments

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.

sebastianbuechler avatar May 14 '24 06:05 sebastianbuechler

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

fzaninotto avatar May 14 '24 07:05 fzaninotto