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

Bug: Making multiple Token calls with same grant type #39

Closed
farhanmalhi-dbank opened this issue Nov 25, 2022 · 6 comments
Closed

Bug: Making multiple Token calls with same grant type #39

farhanmalhi-dbank opened this issue Nov 25, 2022 · 6 comments

Comments

@farhanmalhi-dbank
Copy link

When i login, it makes two token call, with same request having same grant type: authorization_code

Sharing screen shots for reference

Screenshot 2022-11-26 at 1 29 23 AM
Screenshot 2022-11-26 at 1 29 12 AM

@farhanmalhi-dbank
Copy link
Author

farhanmalhi-dbank commented Nov 25, 2022

@soofstad Just an update which i figured out, the cause of this is

root.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>
);

i.e if we use React.StrictMode which makes react components render twice and due to this Token endpoint is called twice.
Please fix this
Thanks

@soofstad
Copy link
Owner

This is how StrictMode works for react 18 at the moment. With no way of disabling it for specific components (ref: facebook/react#16362).

Any suggestions to how this could be solved are welcome.

@sebastianvitterso
Copy link
Collaborator

Just to add to this: According to Dan Abramov (co-author of create-react-app), these duplicated requests should pose no issue, and only happen in development mode. If you try and bundle your app, and then run the bundled code, your requests should only happen once. This is apparently an intentional of React 18 <StrictMode />.

Source: facebook/react#24502 (comment)

@farhanmalhi-dbank
Copy link
Author

farhanmalhi-dbank commented Nov 28, 2022

@sebastianvitterso Yes, i agree. It only happens in development mode.

@sebastianvitterso
Copy link
Collaborator

Good to verify! I don't think there's anything this library can do to remedy this effect (considering it is a deliberate function of StrictMode). Feel free to close the issue, unless there's anything else.

@farhanmalhi-dbank
Copy link
Author

@sebastianvitterso Yes, you are right on this. Lets just wait for any update on Strict mode and I am closing this issue. If later on i found any fix or any update beneficial for this issue. I'll post.

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

No branches or pull requests

3 participants