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

Signout only works after some time has passed #1538

Closed
5 tasks
zestsystem opened this issue Mar 17, 2021 · 7 comments · Fixed by #1557
Closed
5 tasks

Signout only works after some time has passed #1538

zestsystem opened this issue Mar 17, 2021 · 7 comments · Fixed by #1557
Labels
bug Something isn't working

Comments

@zestsystem
Copy link

Your question

I'm having a hard time getting signout to work.

Signin and signout work in development and this bug happens only in production. When I give my app some time to idle and then try to sign out then it SOMETIMES works.

The error message I get is:
[next-auth][error][client_fetch_error]
https://next-auth.js.org/errors#client_fetch_error csrf TypeError: Failed to fetch
and also:
Uncaught (in promise) TypeError: Failed to fetch

The network console shows signout request as pending and its form data's csrfToken as undefined

Just in case this is relevant, I am using a custom login page and I find that even when I'm signing in with facebook the request gets the EmailSignin error. But facebook oauth still goes through and also this sign out issue occurs when I have signed in with email too, so I'm not sure.

Thank you very much and any help would be greatly appreciated.

What are you trying to do

I am trying to get signout to work.

Reproduction

Feedback
Documentation refers to searching through online documentation, code comments and issue history. The example project refers to next-auth-example.

  • Found the documentation helpful
  • Found documentation but was incomplete
  • Could not find relevant documentation
  • Found the example project helpful
  • Did not find the example project helpful
@zestsystem zestsystem added the question Ask how to do something or how something works label Mar 17, 2021
@zestsystem
Copy link
Author

On vercel's real-time function log I get this error every time I try to sign out.

20:23:47:56
[POST] /api/auth/_log
20:23:45:47
Loaded env from .env.production
2021-03-20T03:23:55.522Z 48524c55-80a0-4453-aa8c-05e7ef9b9641 Task timed out after 10.01 seconds

@balazsorban44
Copy link
Member

@mikeyim337 I think I found the problem, thanks to your additional log information from Vercel! Thank you!

@balazsorban44 balazsorban44 added bug Something isn't working and removed question Ask how to do something or how something works labels Mar 20, 2021
@github-actions
Copy link

🎉 This issue has been resolved in version 3.13.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@zestsystem
Copy link
Author

zestsystem commented Mar 20, 2021

@mikeyim337 I think I found the problem, thanks to your additional log information from Vercel! Thank you!

Thank you for the reply.

This fix did clear up all the errors from vercel's logger, but I still get the client_fetch_error and csrf token as undefined in my signout request, so I'm still unable to sign out.

In the network tab I find that my csrf request keeps getting canceled and returns 304 instead of 200 OK.

my nextauth url is NEXTAUTH_URL=https://mydomain.org/ in .env.production.

Thanks for the help. Please reopen this issue if you can.

@balazsorban44 balazsorban44 reopened this Mar 20, 2021
@zestsystem
Copy link
Author

Figured it out. I put the onclick signout method on a live link so it was redirecting before it could sign out. Oops!

@balazsorban44
Copy link
Member

Awesome, thanks for reporting back!

@github-actions
Copy link

🎉 This issue has been resolved 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
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants