Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Truncate debug logs at the start, not the end #3484

Merged
merged 1 commit into from
Sep 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/rageshake/rageshake.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ class IndexedDBLogStore {
const objectStore = db.transaction("logs", "readonly").objectStore("logs");

return new Promise((resolve, reject) => {
const query = objectStore.index("id").openCursor(IDBKeyRange.only(id), 'next');
const query = objectStore.index("id").openCursor(IDBKeyRange.only(id), 'prev');
let lines = '';
query.onerror = (event) => {
reject(new Error("Query failed: " + event.target.errorCode));
Expand All @@ -269,10 +269,10 @@ class IndexedDBLogStore {
resolve(lines);
return; // end of results
}
lines += cursor.value.lines;
if (lines.length >= MAX_LOG_SIZE) {
if (lines.length + cursor.value.lines.length >= MAX_LOG_SIZE && lines.length > 0) {
resolve(lines);
} else {
lines = cursor.value.lines + lines;
cursor.continue();
}
};
Expand Down