From 325839f9fdc151514ff6435b6f95e3b7e1997219 Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Sat, 30 Jul 2011 13:33:16 +0100 Subject: [PATCH] Handle Changeset missmatch gracefully --- node/handler/PadMessageHandler.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/node/handler/PadMessageHandler.js b/node/handler/PadMessageHandler.js index 3d3feb23d..6a7c99631 100644 --- a/node/handler/PadMessageHandler.js +++ b/node/handler/PadMessageHandler.js @@ -415,9 +415,13 @@ function handleUserChanges(client, message) function (callback) { var prevText = pad.text(); - if (Changeset.oldLen(changeset) != prevText.length) { - throw "Can't apply USER_CHANGES "+changeset+" with oldLen " - + Changeset.oldLen(changeset) + " to document of length " + prevText.length; + + if (Changeset.oldLen(changeset) != prevText.length) + { + console.log("Can't apply USER_CHANGES "+changeset+" with oldLen " + Changeset.oldLen(changeset) + " to document of length " + prevText.length); + client.json.send({disconnect:"badChangeset"}); + callback(); + return; } var thisAuthor = sessioninfos[client.id].author;