Skip to content

Commit 252cde0

Browse files
committed
fix: improve telemetry log processing to prevent OOM
1 parent 9890e21 commit 252cde0

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

evals/test-rig.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,19 +210,20 @@ export class TestRig {
210210
readToolLogs() {
211211
if (!existsSync(this.telemetryLog)) return [];
212212
const stats = statSync(this.telemetryLog);
213-
if (stats.size > 500 * 1024 * 1024) {
213+
if (stats.size > 300 * 1024 * 1024) {
214214
throw new Error(
215215
`Telemetry log file is too large (${stats.size} bytes). Possible infinite loop.`,
216216
);
217217
}
218-
// Use Buffer to avoid string length limits for very large logs
219-
const buffer = readFileSync(this.telemetryLog);
220-
const content = buffer.toString('utf-8');
218+
219+
const content = readFileSync(this.telemetryLog, 'utf-8');
220+
// Telemetry logs are NDJSON (one JSON object per line)
221221
return content
222-
.split(/(?<=})\s*(?={)/)
223-
.map((obj) => {
222+
.split('\n')
223+
.filter((line) => line.trim().length > 0)
224+
.map((line) => {
224225
try {
225-
return JSON.parse(obj.trim());
226+
return JSON.parse(line);
226227
} catch {
227228
return null;
228229
}

0 commit comments

Comments
 (0)