mirror of
https://github.com/element-hq/element-web
synced 2024-11-24 10:15:43 +03:00
Merge pull request #4608 from matrix-org/poljar/eventindex-null-token
Handle null tokens in the crawler loop.
This commit is contained in:
commit
af286ade4e
1 changed files with 23 additions and 8 deletions
|
@ -489,14 +489,20 @@ export default class EventIndex extends EventEmitter {
|
||||||
return object;
|
return object;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create a new checkpoint so we can continue crawling the room for
|
let newCheckpoint;
|
||||||
// messages.
|
|
||||||
const newCheckpoint = {
|
// The token can be null for some reason. Don't create a checkpoint
|
||||||
roomId: checkpoint.roomId,
|
// in that case since adding it to the db will fail.
|
||||||
token: res.end,
|
if (res.end) {
|
||||||
fullCrawl: checkpoint.fullCrawl,
|
// Create a new checkpoint so we can continue crawling the room
|
||||||
direction: checkpoint.direction,
|
// for messages.
|
||||||
};
|
newCheckpoint = {
|
||||||
|
roomId: checkpoint.roomId,
|
||||||
|
token: res.end,
|
||||||
|
fullCrawl: checkpoint.fullCrawl,
|
||||||
|
direction: checkpoint.direction,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (let i = 0; i < redactionEvents.length; i++) {
|
for (let i = 0; i < redactionEvents.length; i++) {
|
||||||
|
@ -506,6 +512,15 @@ export default class EventIndex extends EventEmitter {
|
||||||
|
|
||||||
const eventsAlreadyAdded = await indexManager.addHistoricEvents(
|
const eventsAlreadyAdded = await indexManager.addHistoricEvents(
|
||||||
events, newCheckpoint, checkpoint);
|
events, newCheckpoint, checkpoint);
|
||||||
|
|
||||||
|
// We didn't get a valid new checkpoint from the server, nothing
|
||||||
|
// to do here anymore.
|
||||||
|
if (!newCheckpoint) {
|
||||||
|
console.log("EventIndex: The server didn't return a valid ",
|
||||||
|
"new checkpoint, not continuing the crawl.", checkpoint);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// If all events were already indexed we assume that we catched
|
// If all events were already indexed we assume that we catched
|
||||||
// up with our index and don't need to crawl the room further.
|
// up with our index and don't need to crawl the room further.
|
||||||
// Let us delete the checkpoint in that case, otherwise push
|
// Let us delete the checkpoint in that case, otherwise push
|
||||||
|
|
Loading…
Reference in a new issue