From 04acf069d1600f097805ce52f958263e68e153c1 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Tue, 16 Aug 2022 19:33:34 +0300 Subject: [PATCH] ignore invalid journal entries --- src/modules/serverSideStorage.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/modules/serverSideStorage.js b/src/modules/serverSideStorage.js index 08b11b0b..56164be7 100644 --- a/src/modules/serverSideStorage.js +++ b/src/modules/serverSideStorage.js @@ -132,7 +132,15 @@ export const _mergeFlags = (recent, stale, allFlagKeys) => { } const _mergeJournal = (...journals) => { - const allJournals = flatten(journals.map(j => Array.isArray(j) ? j : [])) + // Ignore invalid journal entries + const allJournals = flatten( + journals.map(j => Array.isArray(j) ? j : []) + ).filter(entry => + Object.prototype.hasOwnProperty.call(entry, 'path') && + Object.prototype.hasOwnProperty.call(entry, 'operation') && + Object.prototype.hasOwnProperty.call(entry, 'args') && + Object.prototype.hasOwnProperty.call(entry, 'timestamp') + ) const grouped = groupBy(allJournals, 'path') const trimmedGrouped = Object.entries(grouped).map(([path, journal]) => { // side effect