Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/node/handler/PadMessageHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,14 +465,17 @@ function handleUserChanges(client, message)
var baseRev = message.data.baseRev;
var wireApool = (new AttributePool()).fromJsonable(message.data.apool);
var changeset = message.data.changeset;
// The client might disconnect between our callbacks. We should still
// finish processing the changeset, so keep a reference to the session.
var thisSession = sessioninfos[client.id];

var r, apool, pad;

async.series([
//get the pad
function(callback)
{
padManager.getPad(sessioninfos[client.id].padId, function(err, value)
padManager.getPad(thisSession.padId, function(err, value)
{
if(ERR(err, callback)) return;
pad = value;
Expand Down Expand Up @@ -525,7 +528,11 @@ function handleUserChanges(client, message)
if(ERR(err, callback)) return;

changeset = Changeset.follow(c, changeset, false, apool);
callback(null);
if ((r - baseRev) % 200 == 0) { // don't let the stack get too deep
async.nextTick(callback);
} else {
callback(null);
}
});
},
//use the callback of the series function
Expand All @@ -545,9 +552,7 @@ function handleUserChanges(client, message)
return;
}

var thisAuthor = sessioninfos[client.id].author;

pad.appendRevision(changeset, thisAuthor);
pad.appendRevision(changeset, thisSession.author);

var correctionChangeset = _correctMarkersInPad(pad.atext, pad.pool);
if (correctionChangeset) {
Expand Down