Merge pull request #21928 from mario-mui/fix/big-size-log-error

fix: when use LogViewer with big size(more then 30M maybe) logs cause…
This commit is contained in:
Fredrik Adelöw
2023-12-19 10:54:24 +01:00
committed by GitHub
2 changed files with 7 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/core-components': patch
---
Fixes a problem where the `LogViewer` was not able to handle very large logs
@@ -117,7 +117,7 @@ export class AnsiProcessor {
return this.lines;
}
if (text.startsWith(this.text)) {
if (this.text && text.startsWith(this.text)) {
const lastLineIndex = this.lines.length > 0 ? this.lines.length - 1 : 0;
const lastLine = this.lines[lastLineIndex] ?? new AnsiLine();
const lastChunk = lastLine.lastChunk();
@@ -130,7 +130,7 @@ export class AnsiProcessor {
lastLine.replaceLastChunk(newLines[0]?.chunks);
this.lines[lastLineIndex] = lastLine;
this.lines.push(...newLines.slice(1));
this.lines = this.lines.concat(newLines.slice(1));
} else {
this.lines = this.processLines(text);
}