nhost-dart icon indicating copy to clipboard operation
nhost-dart copied to clipboard

JWTExpired errors after leaving the app open for a short while

Open spakanati opened this issue 3 years ago • 5 comments
trafficstars

I'm seeing JWTExpired errors when leaving the app open for a bit, suggesting the token refresh is not working correctly. It's a dealbreaker right now in terms of being able to use nhost in production because after a fairly short amount of time the app breaks because all queries/mutations/subscriptions stop executing and you have to refresh the entire app.

Similar to #21 but the errors I'm seeing are for any type of operation, not just subscriptions, so I don't think it's purely a websocket problem. I also saw https://github.com/nhost/nhost/issues/405 and it seems that the JS library had a very similar issue, so it might be that the Dart/Flutter library needs to implement the same logic to make sure that the app does not allow the JWT to expire.

spakanati avatar Oct 27 '22 08:10 spakanati

Did you try simple implementation of this without any extra code? i am leaving my app open when i.e. eating lunch and it never yelled at me, that the token expired. After like 2 months of using it, i didnt have this problem once.

MichalNemec avatar Oct 31 '22 15:10 MichalNemec

Can you try latest BETA version https://pub.dev/packages/nhost_sdk/versions/4.0.0-dev.8

It reuiqres you to pass subdomain and region

mhadaily avatar Jan 11 '23 12:01 mhadaily

It's still there in 4.0.0.dev.13

User gets logged out after some time, automatically. Using all dependencies with 3.x-dev.x versions. Any hints?

arckid avatar Feb 12 '23 09:02 arckid

please use new package https://pub.dev/packages/nhost_dart I will depreciate the old package soon.

There is a maximum expiry date for the token however refresh token is issued, therefore, you can silently call the Refresh method to renew the token. This will avoid logout user

Please see this https://github.com/nhost/nhost-dart/issues/91#issuecomment-1378566909

mhadaily avatar Feb 12 '23 09:02 mhadaily

Hi,

Thanks for the quick update. Will go through it and let you know how it goes!

arckid avatar Feb 12 '23 13:02 arckid