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

Fix useSession loading state #1468

Merged
merged 1 commit into from
Mar 7, 2021
Merged

Conversation

ValentinH
Copy link
Contributor

@ValentinH ValentinH commented Mar 7, 2021

Fixes #1467

The issue was due to doing the setLoading(false) in the finally: as we can do an early return here, we would still go to the finally and mark the session as being loaded.

I simply removed the finally block to only set the loading state to false when:

  • the data is ready
  • an error occurs

This is fixing nextauthjs#1467.

The issue was due to doing the `setLoading(false)` in the finally:  as we can do an early return [here](https://github.com/nextauthjs/next-auth/blob/a7e08e2a3266efa9c82eb859e7141c798fcf07ae/src/client/index.js#L100-L100), we would still go to the finally and mark the session as being loaded.

I simply removed the `finally` block to only set the `loading` state to false when:
- the data is ready
- an error occures
@vercel
Copy link

vercel bot commented Mar 7, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/nextauthjs/next-auth/GomadFpHYjfkAcYvjRca84kwF9j3
✅ Preview: https://next-auth-git-fork-valentinh-fix-1467-nextauthjs.vercel.app

@vercel vercel bot temporarily deployed to Preview March 7, 2021 15:57 Inactive
@github-actions github-actions bot added client Client related code core Refers to `@auth/core` labels Mar 7, 2021
Copy link
Member

@balazsorban44 balazsorban44 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right! Thanks for catching this 🙂

@balazsorban44 balazsorban44 merged commit e553573 into nextauthjs:main Mar 7, 2021
@github-actions
Copy link

github-actions bot commented Mar 7, 2021

🎉 This PR is included in version 3.11.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions
Copy link

🎉 This PR is included in version 4.0.0-next.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client Client related code core Refers to `@auth/core`
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Always redirected to /auth/signin after updating to 3.8.0
2 participants