josephg / ShareJS

Collaborative editing in any app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Handling server restart gracefully

MisterTea opened this issue · comments

Hey ShareJS team,

I'm using the inmemory livedb. When my server restarts, the documents are destroyed, which is fine. The problem is that there seems to be no way to notify clients that their document is destroyed. As a client, this is what the log shows:

 GET http://localhost:3000/channel/bind?a=jr35f2vb5gtv&VER=8&RID=rpc&SID=6jux6ccm&CI=1&AID=2&TYPE=xmlhttp&zx=b7zhvc9i4rm3&t=1 net::ERR_CONNECTION_REFUSED
bcsocket.js:46 GET http://localhost:3000/channel/bind?a=jr35f2vb5gtv&VER=8&RID=rpc&SID=6jux6ccm&CI=1&AID=2&TYPE=xmlhttp&zx=pkj9d2i2n4et&t=2 net::ERR_CONNECTION_REFUSED
bcsocket.js:46 GET http://localhost:3000/channel/bind?a=jr35f2vb5gtv&VER=8&RID=rpc&SID=6jux6ccm&CI=1&AID=2&TYPE=xmlhttp&zx=bxr9rhy31zg3&t=3 net::ERR_CONNECTION_REFUSED
bcsocket.js:46 GET http://localhost:3000/channel/bind?a=jr35f2vb5gtv&VER=8&RID=rpc&SID=6jux6ccm&CI=1&AID=2&TYPE=xmlhttp&zx=55p6if8b7u9k&t=4 

Then when the server recovers:

share.uncompressed.js:930 Ignoring attempt to ingest data in state ready

The client stays in this state until the client tries to make a change, upon which the server crashes with "document not found" and the client gets this:

Operation was rejected (Document does not exist). Trying to rollback change locally.
share.uncompressed.js:676 Op apply failed and the operation could not be reverted

I would like to change this behavior so that, when the client reconnects to the server, it detects that the server has restarted. I can then handle the document being destroyed correctly on the client side. Can I catch that "Ignoring attempt to ingest..." warning? How do I handle this case?

Thanks!
Jason G, sole developer of Tidalwave: https://github.com/MisterTea/TidalWave

Have you tried with the latest version from github? There were some changes in the code that made a lot of these notifications more resilient if I remember correctly.