From 5eb510387c9aa08a061d5fd17bed3efc104b48eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Fri, 31 Jan 2020 16:37:30 +0100 Subject: [PATCH] EventIndex: Don't process checkpoints that don't have a valid token. Some rooms might have null as a token, don't add those to be crawled nor to the index. Catch any other errors that might occur during the addition of an initial checkpoint and log them. --- src/indexing/EventIndex.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/indexing/EventIndex.js b/src/indexing/EventIndex.js index 55f8dc9986..ba6c1b6509 100644 --- a/src/indexing/EventIndex.js +++ b/src/indexing/EventIndex.js @@ -115,10 +115,20 @@ export default class EventIndex extends EventEmitter { direction: "f", }; - await indexManager.addCrawlerCheckpoint(backCheckpoint); - await indexManager.addCrawlerCheckpoint(forwardCheckpoint); - this.crawlerCheckpoints.push(backCheckpoint); - this.crawlerCheckpoints.push(forwardCheckpoint); + try { + if (backCheckpoint.token) { + await indexManager.addCrawlerCheckpoint(backCheckpoint); + this.crawlerCheckpoints.push(backCheckpoint); + } + + if (forwardCheckpoint.token) { + await indexManager.addCrawlerCheckpoint(forwardCheckpoint); + this.crawlerCheckpoints.push(forwardCheckpoint); + } + } catch (e) { + console.log("EventIndex: Error adding initial checkpoints for room", + room.roomId, backCheckpoint, forwardCheckpoint, e); + } })); }