From e2cec7b69c720d6159174b3157c3e69ed21029e2 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Thu, 23 Feb 2017 14:22:03 +0000 Subject: [PATCH 1/2] More aggressive rageshake log culling Also bump the client-side timeout on the upload from 3 mins to 5 mins, to see if it helps people on slower connections. --- src/vector/rageshake.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/vector/rageshake.js b/src/vector/rageshake.js index 61e29a312d..5712f24f18 100644 --- a/src/vector/rageshake.js +++ b/src/vector/rageshake.js @@ -314,17 +314,20 @@ class IndexedDBLogStore { let size = 0; for (let i = 0; i < allLogIds.length; i++) { let lines = await fetchLogs(allLogIds[i]); + if (i > 0 && size + lines.length > MAX_LOG_SIZE) { + // the remaining log IDs should be removed. If we go out of + // bounds this is just [] + // + // XXX: there's nothing stopping the current session exceeding + // MAX_LOG_SIZE. We ought to think about culling it. + removeLogIds = allLogIds.slice(i + 1); + break; + } logs.push({ lines: lines, id: allLogIds[i], }); size += lines.length; - if (size > MAX_LOG_SIZE) { - // the remaining log IDs should be removed. If we go out of - // bounds this is just [] - removeLogIds = allLogIds.slice(i + 1); - break; - } } if (removeLogIds.length > 0) { console.log("Removing logs: ", removeLogIds); @@ -485,6 +488,7 @@ module.exports = { user_agent: userAgent, }, json: true, + timeout: 5 * 60 * 1000, }, (err, res) => { if (err) { reject(err); From 038f5767f2321f1b414f6b1bd26b455440bc01ee Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Thu, 23 Feb 2017 14:37:46 +0000 Subject: [PATCH 2/2] Add a comment --- src/vector/rageshake.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/vector/rageshake.js b/src/vector/rageshake.js index 5712f24f18..09acca44e7 100644 --- a/src/vector/rageshake.js +++ b/src/vector/rageshake.js @@ -314,6 +314,9 @@ class IndexedDBLogStore { let size = 0; for (let i = 0; i < allLogIds.length; i++) { let lines = await fetchLogs(allLogIds[i]); + + // always include at least one log file, but only include + // subsequent ones if they won't take us over the MAX_LOG_SIZE if (i > 0 && size + lines.length > MAX_LOG_SIZE) { // the remaining log IDs should be removed. If we go out of // bounds this is just [] @@ -323,6 +326,7 @@ class IndexedDBLogStore { removeLogIds = allLogIds.slice(i + 1); break; } + logs.push({ lines: lines, id: allLogIds[i],