fix(server): deal with unexpected updates (#4064)

This commit is contained in:
liuyi
2023-08-31 16:56:33 +08:00
committed by GitHub
parent 9bffe3cf24
commit e10868cd20
3 changed files with 26 additions and 10 deletions

View File

@@ -67,8 +67,17 @@ export class DocManager implements OnModuleInit, OnModuleDestroy {
protected recoverDoc(...updates: Buffer[]): Doc {
const doc = new Doc();
updates.forEach(update => {
applyUpdate(doc, update);
updates.forEach((update, i) => {
try {
if (update.length) {
applyUpdate(doc, update);
}
} catch (e) {
this.logger.error(
`Failed to apply updates, index: ${i}`,
updates.map(u => u.toString('hex'))
);
}
});
return doc;