do not crash when encountering mismatched compositions. log the changesets and padid

This commit is contained in:
webzwo0i 2015-02-26 14:57:49 +01:00
parent 38a4f1be5f
commit 7719117e1e
2 changed files with 9 additions and 5 deletions

View File

@ -1629,10 +1629,14 @@ function composePadChangesets(padId, startNum, endNum, callback)
changeset = changesets[startNum];
var pool = pad.apool();
for(var r=startNum+1;r<endNum;r++)
{
var cs = changesets[r];
changeset = Changeset.compose(changeset, cs, pool);
try {
for(var r=startNum+1;r<endNum;r++) {
var cs = changesets[r];
changeset = Changeset.compose(changeset, cs, pool);
}
} catch(e){
console.warn("failed to compose cs in pad:",padId);
return;
}
callback(null);

View File

@ -1318,7 +1318,7 @@ exports.compose = function (cs1, cs2, pool) {
var unpacked2 = exports.unpack(cs2);
var len1 = unpacked1.oldLen;
var len2 = unpacked1.newLen;
exports.assert(len2 == unpacked2.oldLen, "mismatched composition of two changesets");
exports.assert(len2 == unpacked2.oldLen, "mismatched composition of two changesets - cs1:",cs1," and cs2:",cs2);
var len3 = unpacked2.newLen;
var bankIter1 = exports.stringIterator(unpacked1.charBank);
var bankIter2 = exports.stringIterator(unpacked2.charBank);