-
Notifications
You must be signed in to change notification settings - Fork 140
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
Page does hard refresh when session invalidated #261
Comments
@Redsandro This library never does anything to cause a page refresh. Can you post the code needed to reproduce this behavior so I can take a look? |
Triggering
When token-refresh fails ( And when the session expires ( This causes But I am not extending it. I don't know why the refresh happens. |
@Redsandro Are you able to provide a complete example of this behavior? I can't reproduce the behavior with the information provided and I don't see anything that would cause this behavior. In all of my applications using this library, there is not a hard refresh when |
@fenichelar it's not easy because some code is not mine/libre, and I would need to spoof the backend and everything. I will explore opinions from upstream first. If I can't get a hint as to what might cause this, I will go the extra miles. Although there has to be a way to listen for an event and track what triggered it. |
That's interesting, because I got word from upstream that:
How do your apps prevent it from happening? |
Wait, just to be clear... are you using both Application adapter:
Application router:
|
On closer examination, I don't believe I am using |
I take it back, I think |
Ah, okay, I get it. That's because you don't use the I think I might be using this wrong. I assumed I needed
Indeed, |
(Btw, setting |
|
I just did a quick test with |
JWT session expiration time is 15 seconds, and refreshLeeway 10, so that I only need to wait 5 seconds to test this out. |
I can't seem to reproduce this, can you provide a working sample? |
Closing. Let me know if you still have this issue. |
It's doing this to me too. Somewhere in the code it's triggering a hard refresh and losing the token state. This only happens locally for me. |
I've tried just copying the local storage from my production app (as it's pointing to the same database) but that gets replaced immediately. No errors anywhere in the logs. |
|
@fenichelar thank you so much for replying I really appreciate it.
What is mysterious to me is this behavior doesn't occur in production: https://www.ceqr.app. Further context, I've inherited this app and am unsure how to proceed. I just cannot get it to authenticate. Attempts to cUrl the login endpoint in the backend work fine — they return the token. I can even observe a 200 OK response in the frontend. But I get a "transition aborted" — unless it's a red herring, it seems to be interrupting and I don't know why. |
@allthesignals Thank you. I'm not completely following what the issue is. Can you walk through what is happening in a little more detail? |
Yes, here's what I'm observing: This is local development. When I successfully login (I am confirm through backend logs), it seems to try to transition to a new route, but does a hard refresh instead. This hard refresh causes the token to never be persisted in memory in the application instance. This doesn't seem to occur in the production deployment of the site. Even a vague guess at what is causing this would help... Thank you! |
Can you expend the transition aborted console log and provide the full output? |
Yes — I don't think it's very helpful though. I think something more serious is being buried... let me see if I have an error hook in a route somewhere: "TransitionAborted: TransitionAborted |
Ah, here's some more information (There indeed was an error hook swallowing up valuable information): Okay, so the transitionAbort error might be happening because of an immediate 401: Error: Ember Data Request GET http://localhost:3000/api/v1/projects returned a 401 So that invalidates something probably and causes a refresh or navigation to login? Looking at the XHR history is interesting: What's odd about the "successful" login request is that it fails to load the response data? I'm not sure if this is even how browsers behave, but perhaps there's some race condition. EDIT: Plot thickens... TypeError: Cannot read property 'email' of undefined |
You can disregard this now... I think this had to do with some weird dep resolutions issues for fetch (competing with jQuery maybe?) The particulars of the faulty fetch shim I was using were probably interfering with how ESA-token makes requests. |
@allthesignals Is everything working now or just the transition? |
Everything is working now but my advice (or shot in the dark) for others would be to make sure there are no weird issues with ember-fetch. The fix described in that issue thread seemed to cause the issue. I got around it by switching to an earlier version of node. |
When
token-refresh
fails, or is too late, or the session invalidates (automatically or manually), the page does a hard refresh. How do I stop this?I still want to "change" my app, so an event would be nice, but I do not want a hard refresh. This is a SPA.
I'm using
authenticator:jwt
and mistakenly posted an issue here: myartsev/ember-simple-auth-jwt#52The text was updated successfully, but these errors were encountered: