mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-05 09:01:18 -04:00
feat(client): truncate long logs in the client rather than test evaluator (#60235)
This commit is contained in:
committed by
GitHub
parent
b629884fea
commit
f606e19a1a
@@ -8,19 +8,14 @@ const ctx: Worker & typeof globalThis = self as unknown as Worker &
|
||||
|
||||
const __utils = (() => {
|
||||
const MAX_LOGS_SIZE = 64 * 1024;
|
||||
const TRUNCATE_AT = 500_000;
|
||||
|
||||
let logs: string[] = [];
|
||||
|
||||
function flushLogs() {
|
||||
if (logs.length) {
|
||||
let data = logs.join('\n');
|
||||
if (data.length > TRUNCATE_AT) {
|
||||
data = `${data.substring(0, TRUNCATE_AT)} Logs truncated. See browser console for more`;
|
||||
}
|
||||
ctx.postMessage({
|
||||
type: 'LOG',
|
||||
data: data
|
||||
data: logs.join('\n')
|
||||
});
|
||||
logs = [];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user