-
-
Notifications
You must be signed in to change notification settings - Fork 192
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
[auth] Bug: Auth currentSession is null #860
Comments
Forgot to mention, on android we cleared app's cache without deleting app and issue resolved also this way. |
This also may help. After initialize()n we listen auth event and also print eventual error.
At the moment I have one client stuck in this situation. If you want me to run some code against it, I can do it. |
Another thing which may be important to know is that this time the issue occurred when we restored a supabase backup. Supabase's support email said that the two things should be unrelated, but maybe it is not a coincidence. If so, that is worth a deeper investigation coz might potentially lead to entire user-base being forced to uninstall app in case we restore a database backup. |
I did run code:
And then also:
LOG: I tried also to dispose instance after
LOG I see event Hope this helps. |
So the issue is that you were signed in on the app, but one day when you opened the app, you were signed out, correct? You say you had to uninstall the app and install it again to fix it (or delete app cache on Android), but if you were signed out, couldn't you have just signed in again (understanding that being signed out randomly is annoying, and should be fixed)? |
I also thought that it could be a signout issue but didnt try to sign in back via I've tried in the past to suggest an ultimate workaround to this problem. Coz it can be solved with a set of recovery tokens issued by Gotrue at signup (and maybe refreshed over time). Simply put: if In any event, can you guys please brainstorm on the flutter client and maybe inspect the code all together. Coz it is a fact that the bug is hard to fix and couldn't be fixed in over one year. We are getting close to our launch date and cannot launch app with this issue. |
Okay, the cause of this issue is most likely the refresh token being invalid for some reason (network connection being interrupted before getting the auth response back when refreshing the session or something). We have a fix coming up on the client that would hopefully resolve it. Thanks for your patients. |
Thx! Could you please also check this? Coz issue also occurred (on all our phones) after we restored an old backup. If that is also an issue, this is serious too. |
@iosephmagno |
@dshukertjr thx for confirming this. Can you please get Auth team's attention on that? In a generic successful scenario, restoring a backup would cause million of users being forced to uninstall app, and they wont even get informed from the company (coz app is dead). I dont want to sound pushy on my idea, whatever the fix is okay for us, but |
No, they would just be signed out, and they can signed back in. There is not much the auth team can do here. That's how backups work. It restores the entire state of your database to a given point in time. It's the last resort in a case of catastrophic data loss, and you as the developer have to understand the consequences. |
Yea I understand this. But let me better explain my thought here. In terms of affected users we can assess they will be most part of entire users base, due to token refresh timing and app nature (Messenger). Ideal case would be that we dont kick off the users who are registered to Auth table. We now kick them off coz we dont have a disaster recovery flow at the moment, but as long as user is inside Auth table and we enable the client to reconnect somehow, kick-off wouldnt be required). Also, considering the very case where user is signed out for some uncovered reason. We should first display a screen where we explain to user the situation and then navigate to signin screen. But, if I remember well, session is temporarily null during app launch, so we would appreciate to have a sample explaining how to do it correctly. |
You performed the backup, and the session info is gone from the database. As far as the database is concerned, the session tokens that those users have are invalid, and there is no way for the users to re-obtain the session other than to re-authenticating.
This I agree. There should be an error passed to the
The session is not null if the user is signed in. There will be a session available with an |
Can you guys please debug the flow by simulating the two cases and add specific errors inside This is the alert we can show in case user gets logged out without real reason. As mentioned, we must avoid this bug 99.999%, but we also must be prepared to deal with it if required. The message is generic and tries to not panic user. Alert: This is the alert we should display in case of a backup restore, if Auth wont enable the client to get a new session anyway through a special flow. The user will be informed properly and wont panic. Alert Does it make sense? |
We will get to it whenever we can 👍 |
Thx! As of now, it seems we cannot code a patch for this coz: For the first panel: we could check if For the second panel: it is not clear whether we should grab the event We should need supabase client throwing either specific errors or state events. It is also unclear whether supabase client can get to distinguish the two events, which both kickoff user but require a different panel with different message. Maybe Gotrue server should return a specific error for the two cases. |
We have shipped an update that will hopefully make things better with this issue. If you could try out v2.5.0 of supabase_flutter and see if things are better, that would be great. |
Great! Will test it and lyk. |
@dshukertjr any news about how to grab these events such to show correct info panel to user? |
@iosephmagno That is a separate issue, so feel free to open a new issue to discuss the matter. |
@dshukertjr user is not added to User table after otp code is verified. |
@iosephmagno I'm going to need more context of what exactly your issue is to look into it. A new row is inserted into the I'm going to close this issue as a fix has been shipped. If the original issue still persists, please feel free to reopen this one. |
@dshukertjr Hi Tyler, it was an Auth backend issue. Thought it was due to this coz I was testing it right when issue occurred. |
@dshukertjr just informing that this occurred again while using latest plugin version ^2.5.6. Since no changes have been done related to this specific issue, we can assume that this is not a regression and Supabase auth flow is still such that Please discuss internally about a "session-recovery-flow" for this case. If my idea to use a "restoreToken" is not liked, you might come up with something different. But as of now, it is almost certain that this issue will occur at least 2-3 times / year and it is not acceptable on mobile apps (users will freak out). Meantime a production-ready solution is implemented, can you guys please instruct us with a flow that can be used to help user navigate through this issue? Maybe kick user off and ask him/her to signin again with some fake reason, like: "This is a security procedure, please signin again". No idea about what else we can do without sounding bad to users. |
Can we please also re-open it so we can track it? There isn't new data for us to submit with a new issue. |
If the I believe you are overreacting to this issue. Although getting signed out 2-3 times a year might not be ideal, it's not something users would freak out. We are constantly trying to make our auth better, and I could only ask you to just patiently wait. |
Yes should be an edge case related to network state during auth flow, which makes debug harder. @dshukertjr, I appreciate much the work done so far on this bug. And I do understand it is tricky to fix (this is why I tried to put on the table that We are not overestimating the severity of the issue. Being getting kicked off from a mobile app (twitter, whatsapp and even the little niche apps) is never happened to nobody. With chat apps, there is extra panic related to the fact that average user cannot distinguish a kick-off from other bad events, so if they see the onboarding screen asking to login back, they just freak out. Those who don't freak out might consider the app to be cheap and might be just tempted to trash it. Please guys do not consider Auth production-ready on mobile until this bug is fixed. |
If fixing bug might require long time, can you please assess again our idea with the Auth team? Flow would be like:
With this minor improvement, it can never happen that a mobile user cannot connect. Also, |
Describe the bug
Hello @dshukertjr just reporting that we were hit but the null auth session bug.
The code is standard one:
auth.currentSession
is null.To fix issue, I had to uninstall app and reinstall it from scratch.
No errors were found on supabase console.
To Reproduce
Unfortunately, there are no clear steps to reproduce the bug. It occurs randomly out of blue. In our case, usually once every 2 months and doesnt autoresolve with app launch, user must delete app.
Expected behavior
Client should always be capable to auto-resolve any auth issue while fetching a new session from GoTrue server.
Version (please complete the following information):
On Linux/macOS
Please run
dart pub deps | grep -E "supabase|gotrue|postgrest|storage_client|realtime_client|functions_client"
in your project directory and paste the output here.Additional context
Issue resolves by uninstalling the app, hence cache is involved. I mean the issue is caused by what the plugin has saved to cache and revert as soon as cache is cleared.
Potential workaround
Since client knows when the
currentSession
is null, can it clear the cache ifcurrentSession
is null after X retry?Thats doesnt fix the root problem but should workaround the issue.
The text was updated successfully, but these errors were encountered: