From cb368a06012918289e1cb14362497cdaae27ecda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Fri, 13 Mar 2020 14:12:48 +0100 Subject: [PATCH] EventIndex: Remove a checkpoint if the HTTP request returns a 403. This fixes https://github.com/vector-im/riot-web/issues/12722. --- src/indexing/EventIndex.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/indexing/EventIndex.js b/src/indexing/EventIndex.js index c8a9a4c1fa..a9c27a254f 100644 --- a/src/indexing/EventIndex.js +++ b/src/indexing/EventIndex.js @@ -373,6 +373,21 @@ export default class EventIndex extends EventEmitter { checkpoint.roomId, checkpoint.token, this._eventsPerCrawl, checkpoint.direction); } catch (e) { + if (e.httpStatus === 403) { + console.log("EventIndex: Removing checkpoint as we don't have ", + "permissions to fetch messages from this room.", checkpoint); + try { + await indexManager.removeCrawlerCheckpoint(checkpoint); + } catch (e) { + console.log("EventIndex: Error removing checkpoint", checkpoint, e); + // We don't push the checkpoint here back, it will + // hopefully be removed after a restart. But let us + // ignore it for now as we don't want to hammer the + // endpoint. + } + continue; + } + console.log("EventIndex: Error crawling events:", e); this.crawlerCheckpoints.push(checkpoint); continue;