unfoldingWord / gateway-edit

Book Package harmonized view.
https://gatewayedit.com
MIT License
1 stars 4 forks source link

Network Error Displays On Login #548

Open theNerd247 opened 1 year ago

theNerd247 commented 1 year ago

The following error dispalys after I've logged into gateway edit (the develop server):

Screenshot 2023-09-19 at 3 41 44 PM

I'm not sure if this is a bug and what the scope of this error is...it's merely a bother at this point; the error is ironic as logging in implies a successful network connection.

birchamp commented 1 year ago

@theNerd247 @elsylambert Is this still happening?

theNerd247 commented 1 year ago

yes, at least on the develop server

elsylambert commented 1 year ago

@theNerd247 I am looking at https://develop--gateway-edit.netlify.app/ and login works fine for me. I just go to the link and enter my credentials and it works. Can you specify the steps you are following? It looks like from your screenshot that you were logged in and were working on the app and then lost connection. Can you also confirm the link: https://develop--gateway-edit.netlify.app/ , is where you are seeing this?

danielklapp commented 1 year ago

@theNerd247 @elsylambert It does work fine with https://develop--gateway-edit.netlify.app/, but I've been logged into the same build for few days (v2.1.0 build 3eff611 QA). I logged out and tried to log in with a different build (v2.1.0 build d431e66 QA) and that error popped up for me as well. Wonder if when logging in for the first time or switching from build to build causes error to pop up.

theNerd247 commented 10 months ago

This issue is occurring more often now on my local machine. This is happening on 3eff611 with a cleared local browser cache. @PhotoNomad0 is there a direction that you could point me in to get fixing this?

kintsoogi commented 10 months ago

This occurs every time I switch to a different URL to use gateway edit. For example, if I switch from my local instance in localhost to the develop server this error appears and I have to log in again.

theNerd247 commented 10 months ago

I've noticed that there is config that is stored in the browser's local storage see this line...and this may be related. Also, I've a hunch the issue has something to do with the switch to using a QA server

theNerd247 commented 10 months ago

I've noticed that there is config that is stored in the browser's local storage see this line.

@larsgson and I collaborated and discovered that the deeper issue is probably the stateful routing that is being done (I've created a spike for this: #600).

A quick solution is to clear the localstorage in the browser - or switch to Chrome (there seems to be less problems there).

PhotoNomad0 commented 10 months ago

@theNerd247 - I saw this error recently, and when I checked the console log I noticed that there was a 401 error fetching authentication information. It looks like what is happening is that I had been testing a deploy preview URL. When I logged in dcs provides a new tokenID and invalidates the older ones for GWE.

Then I went back to testing with localhost which already had an old tokenID saved. When I launched GWE it tries to use the old tokenID (which has been invalidated). Unfortunately the error message is just a generic network error message. Instead the GWE behavior should be to go to the login page if the tokenID fails with a 401 error. Or maybe change the startup workflow to validate the tokenID before using it.

@richmahn Any suggestions what is the best approach?

@elsylambert @danielklapp @birchamp

@theNerd247 Thanks for creating this issue - I probably should have created one a while ago. Instead I was just working around the problem by going to login page and logging in again.

PhotoNomad0 commented 10 months ago

@elsylambert @danielklapp @birchamp - As far as the magnitude of the problem, users normally just use the released URL to open GWE. But they still may see this problem if they switch to a different browser.

PhotoNomad0 commented 10 months ago

@theNerd247 @kintsoogi - In setting a breakpoint, I see that runMergeHandler() is being called before the tokenID is validated. So we will also have to make a fix in useBranchMerger also.

PhotoNomad0 commented 10 months ago

@theNerd247 @kintsoogi - OK, found the core error in AuthContext getAuth(). The library called by doFetch() is throwing an exception on 401 errors, rather than just returning the status code that getAuth() expects. So the fix should be easy.