Signing in with `exitTo` doesn't work
See original GitHub issueIf you haven’t already, check out our contributing guidelines for onboarding!
Platform - version: Desktop web (all?)
Action Performed (reproducible steps):
- Sign in as normal
- Navigate to a report
- Click “Sign out”
- Note that there is an
exitTo
in the URL - Enter an email address to sign in
- Note that it hangs there forever
Expected Result: Expected to see password/2FC page
Actual Result: Hung with a spinner forever
Notes/Photos/Videos:
Logs - JS/Android/iOS (if applicable):
Issue Analytics
- State:
- Created 3 years ago
- Comments:16 (5 by maintainers)
Top Results From Across the Web
Exit function stopped working - Power Platform Community
Signout is useful when devices are shared to ensure user security. While authoring the app, calling Exit doesn't exit or sign out the...
Read more >Why does my exit() command not work in python?
SystemExit is special in two ways: It doesn't dump a traceback and exit with a fixed status 1 if unhandled (it just silently...
Read more >What's wrong with exit command on my terminal?
When you exited, your session was closed - but you opened this session as a user, so you get back to your user...
Read more >Troubleshoot the AWS Glue error "Command failed with exit ...
My AWS Glue extract, transform, and load (ETL) job fails with the error "Command failed with exit code". Short description. You get this...
Read more >I received an error message saying, “You've reached the ...
To fix this issue, you will need to close your Internet browser and open it back up before trying to log in again....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I was able to reproduce it only with switching tab and coming back to the sign in tab. I’m not sure if others, who reproduced it, switched the tab in the process, but this flow has 100% reproducibility (thanks, @TheRohitSharma).
There was a post in the Slack about new steps for contributors:
Even though I’m itching to write the pull request, I’ll post the solution first.
Steps to reproduce
The root cause
This is a combination of two issues.
When
ReportActionsView
is mounted, it adds an event listener for the app visibility change (remember the tab switching?)So on each app visibility change, the function
recordMaxAction
will be called, and it will send the request to the server to update last read action id.And when
ReportActionsView
is unmounting, it should remove this listener:The problem is
AppState.addEventListener
doesn’t really return anything, sothis.visibilityChangeEvent
is undefined after subscription to the event. It means thatcomponentWillUnmount
doesn’t remove the listener.The listener is still active after the sign out.
When user switches to other tab and returns back to the sign in, the event triggers. After 3 seconds timeout, it sends the request. But user is signed out, so server responds with 407 code. API request function calls
handleExpiredAuthToken
to try to relogin user.This is the place where other issue happens.
handleExpiredAuthToken
pauses the network queue and tries to sendAuthenticate
request, using saved credentials. But user is signed out. Socredentials
object is null. So accessingcredentials.autoGeneratedLogin
andcredentials.autoGeneratedPassword
throws an exception, which is not caught.So
handleExpiredAuthToken
ends prematurely. But before it tried to send the request, it paused the Network Queue. And after the exception the queue is still on pause.Now user enters the email and presses “Continue” button.
fetchAccountDetails
request is added to the queue, but queue is on pause, so request will never be sent and “Continue” button forever hangs in loading state.https://user-images.githubusercontent.com/130532/103470075-10e73680-4d76-11eb-8578-94283f4d5c95.mp4
The fix
The fix should include:
credentials
object, or something like this:ReportActionsView
:Prevention of future issues
I’m not sure about it yet.
I could put the request in
handleExpiredAuthToken
totry-catch
block, but we already have the catch for the promise. So this approach would require some duplication of the catch code, because promise rejection will not be caught bytry-catch
.I could wrap the whole function content with
Promise.try(() => { ... });
and add the only one parentcatch
, which would handle both promise rejections and params errors. That would be cleaner, but looks a bit weird to me.The cleanest way would be
async/await
withtry/catch
, but you don’t use it anywhere in your code. So that probably makes the №2 approach the winner.@ajimpa That solution alone will not solve this issue since it doesn’t address the underlying cause of this particular bug (which is that we have a network request firing after we have logged out).