cs136 / seashell

Seashell is an online environment for editing, running, and submitting C programming assignments.
GNU General Public License v3.0
38 stars 19 forks source link

Offline Mode Sync breaks with intermittent connections #606

Closed kpsuperplane closed 7 years ago

kpsuperplane commented 7 years ago

I was speaking to a guy in CS 136 who's Seashell kept forgetting his code and losing connection. Turns out his computer was randomly switching between Wifi and Ethernet, thus causing many sudden changes in network connection. Is there anything we can do about this?

kpalway commented 7 years ago

So to confirm: offline mode was enabled, and his Seashell was alternating between running in offline mode and running normally over the websocket connection? Any more detail on what "forgetting code" refers to?

kpsuperplane commented 7 years ago

I assumed offline mode enables automatically when he goes offline? According to him, when his computer lost connection, his changes would be lost and seashell would give him a websocket error.

kpalway commented 7 years ago

Offline mode has to be enabled manually at some point while connected (it saves data locally, so we ask permission first). From then on it will activate automatically when the user loses connection. It's possible that Seashell let him keep typing before realizing there is no network connection, but there is an upper bound on the amount of work lost which is about 10-15 seconds of typing at a conservative estimate.

I would guess that offline mode was not enabled.. I think the solution would be to use offline mode or to fix the network settings to keep a stable connection.

kpsuperplane commented 7 years ago

Yeah, I asked him about his connection and he said it was fine after he unplugged the ethernet. Just wondered if there might be a way to fix this (or at least prevent work being lost upon loss of connection)

kpalway commented 7 years ago

One solution may be to do something smarter when a websocket request to save a file fails, like storing the contents somewhere separate then resolving the difference on reconnection.. but then we're getting into territory that is already covered by all of the offline mode file storage code. I'll look into this, but it may take some time.

e45lee commented 7 years ago

Note: We will probably address this use case when we get around to better integrating the offline mode code with the websocket code. Ideally, we'd use some sort of offline-first model, where the changes first get made to the user's local storage, and we do not block on the write to the server (in most cases).

What happens now is we first attempt to write to the server, then persist locally. This doesn't work if a connection is truly intermittent, as it waits for the websocket to die first.

e45lee commented 7 years ago

This will land with the new React changes, and is complete there, so I'm closing this issue.