Alamantus / Lexiconga

The quick and easy dictionary builder for constructed languages.
https://lexiconga.com
10 stars 2 forks source link

Session not saved if disconnected from internet #16

Closed tsela closed 5 years ago

tsela commented 8 years ago

OK, this issue is weird, but I've seen it happen twice already, and it's made me lose half an hour of work already :(. The main problem is that I haven't been able to reproduce it. It just happens randomly so far.

Here is what happens: I am logged in, and working on a dictionary. I then go to settings to go and save it (an UI issue I will talk about in another issue). What happens is that twice so far, when I go to settings, the "Change Dictionaries" field is empty, rather than containing the name of the dictionary I'm working on. When this happens, I cannot save the work to the cloud, and if I close the browser tab and get on Lexiconga again, I lose all the work I've done once I'm logging in. That's very annoying :(.

I don't know why that problem happens, and I can't seem to be able to reproduce it, but it's happened to me twice already, so it's not just some one-off weirdness...

Addition: just noticed that when this problem happens, closing the browser tab and reopening it brings me to a not-logged in session. while normally closing the browser tab and reopening while logged in should bring me to a logged in session. So it seems the actual issue is random unrequested logging out.

Alamantus commented 8 years ago

Interesting... It sounds like something's up with how the server's PHP engine is handling your session. Can you answer a couple questions for me:

Next time you notice it happen, can you open up the browser's developer console and see if there are any relevant messages regarding be in logged out (or anything other than "added/updated successfully"? Also, if you catch it happening again, I'd recommend exporting your dictionary with the changes you made until I figure out how to fix this for you. I can fix any mistakes you notice didn't get saved if you send me the file.

tsela commented 8 years ago

I'm using Firefox (latest version). I'm not aware this place is switching networks, but it does sometimes lose Internet connectivity for short amounts of time. I have not noticed it doing it when the problem happened, though. Next time it happens, I will check the developer's console and will save my dictionary :).

tsela commented 8 years ago

So, the problem just happened again. Here is the log I get from the developer console:

`updated successfully dictionaryBuilder.js: 483:13

updated successfully dictionaryBuilder.js: 539:17

updated successfully dictionaryBuilder.js: 483:13

updated successfully dictionaryBuilder.js: 539:17

ReferenceError: event is not defined ui.js:133:9

SubmitWordOnCtrlEnter() ui.js:133

onkeydown() /:1

not signed in dictionaryBuilder.js:483:13

ReferenceError: event is not defined ui.js:133:9

SubmitWordOnCtrlEnter() ui.js:133

onkeydown() /:1

not signed in dictionaryBuilder.js: 483:13

not signed in dictionaryBuilder.js: 543:17

ReferenceError: event is not defined ui.js:133:9

SubmitWordOnCtrlEnter() ui.js:133

onkeydown() /:1

not signed in dictionaryBuilder.js: 483:13

ReferenceError: event is not defined ui.js:133:9

SubmitWordOnCtrlEnter() ui.js:133

onkeydown() /:1

not signed in dictionaryBuilder.js: 483:13

not signed in dictionaryBuilder.js: 543:17 `

Can you make sense of it? By the way, no need to send you the dictionary. I made sure I only make small changes before each save. I don't have much work to recover :).

tsela commented 8 years ago

OK, now that's weird: additional issue: I did save the dictionary as a .dict file before logging in again. However, saving it didn't save the last changes I made! In other words, the .dict file I got is identical to the dictionary I got back when I logged in. So I ended up losing my work anyway :(. Luckily it was just a few lines, but still...

Alamantus commented 8 years ago

Oh yikes, that doesn't sound good. So it looks like the system is logging you out for some reason, and I don't know why it would do that. If often keeps me logged in even if I leave my browser, so I'm not sure why the discrepancy is there...

I'm not sure why the .dict file would be wrong if you made changes, especially if you made the changes while you were not logged in. Any changes made while not logged in get saved to your browser cache, so it should all be there... Very strange.

I'm out of the country right now and have limited access to Internet and dev environment, but I'll look into it as I can and report back when I find anything out!

tsela commented 8 years ago

Oh yikes, that doesn't sound good. So it looks like the system is logging you out for some reason, and I don't know why it would do that. If often keeps me logged in even if I leave my browser, so I'm not sure why the discrepancy is there...

For what is worth, I think I found the reason: a flaky Internet connection. I had the issue again, and this time I had another website on another tab open at the same time, and that one complained of having lost connection and trying to reconnect (which it did, after a few seconds). So it looks like Lexiconga simply loses the session when the Internet connection is lost, and does not automatically reconnect when it's back.

I'm not sure why the .dict file would be wrong if you made changes, especially if you made the changes while you were not logged in. Any changes made while not logged in get saved to your browser cache, so it should all be there... Very strange.

What it looks like, to me at least, is that when the session is lost due to a broken Internet connection, at least part of the website thinks it still is logged in, but there's no dictionary available. Don't forget the main symptom of this problem is that the Dictionary field in Settings is empty. So making any changes is not going to work, since it thinks there is basically no dictionary at the moment. Maybe that's also why the changes do not get saved to the browser cache.

All in all, it looks like it simply does not recover gracefully from a flaky Internet connection. Maybe you could test that when you have time by simply cutting of the Internet on your computer while having a logged-in session open in your browser, and see what happens...

Alamantus commented 8 years ago

I finally just thought of a solution to gracefully reconnect logged in sessions: session tokens saved as browser cookies! If there is ever a disconnection while trying to save, it will attempt to reconnect using the token and upon successful reconnection, it will upload the whole dictionary to save any and all changes made while it was offline.

I'll start working on this as soon as I am able.

tsela commented 8 years ago

Sounds like what they're doing on the ShareLaTeX site, which is a good thing :). And the additional benefit of this, if you like implementing it, is persistent sessions even across tab or even browser closing. I like at least having the option to have the site "remember me", so I don't have to log in every time I get to the site. Maybe something you could consider now that you're considering cookies.

Alamantus commented 5 years ago

July 1st release will help fix this issue