Skip to content

Commit bb4d8ee

Browse files
authored
Merge pull request element-hq#3311 from vector-im/rav/rageshake_culling
More aggressive rageshake log culling
2 parents 6690df1 + 038f576 commit bb4d8ee

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

‎src/vector/rageshake.js‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -314,17 +314,24 @@ class IndexedDBLogStore {
314314
let size = 0;
315315
for (let i = 0; i < allLogIds.length; i++) {
316316
let lines = await fetchLogs(allLogIds[i]);
317-
logs.push({
318-
lines: lines,
319-
id: allLogIds[i],
320-
});
321-
size += lines.length;
322-
if (size > MAX_LOG_SIZE) {
317+
318+
// always include at least one log file, but only include
319+
// subsequent ones if they won't take us over the MAX_LOG_SIZE
320+
if (i > 0 && size + lines.length > MAX_LOG_SIZE) {
323321
// the remaining log IDs should be removed. If we go out of
324322
// bounds this is just []
323+
//
324+
// XXX: there's nothing stopping the current session exceeding
325+
// MAX_LOG_SIZE. We ought to think about culling it.
325326
removeLogIds = allLogIds.slice(i + 1);
326327
break;
327328
}
329+
330+
logs.push({
331+
lines: lines,
332+
id: allLogIds[i],
333+
});
334+
size += lines.length;
328335
}
329336
if (removeLogIds.length > 0) {
330337
console.log("Removing logs: ", removeLogIds);
@@ -485,6 +492,7 @@ module.exports = {
485492
user_agent: userAgent,
486493
},
487494
json: true,
495+
timeout: 5 * 60 * 1000,
488496
}, (err, res) => {
489497
if (err) {
490498
reject(err);

0 commit comments

Comments
 (0)