test: simplify cache live trace parsing · openclaw/openclaw@e3a3093
steipete
·
2026-05-09
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -121,12 +121,17 @@ async function readCacheTraceEvents(sessionId: string): Promise<CacheTraceEvent[
|
121 | 121 | throw new Error("live cache trace file not initialized"); |
122 | 122 | } |
123 | 123 | const raw = await fs.readFile(liveCacheTraceFile, "utf8").catch(() => ""); |
124 | | -return raw |
125 | | -.split("\n") |
126 | | -.map((line) => line.trim()) |
127 | | -.filter(Boolean) |
128 | | -.map((line) => JSON.parse(line) as CacheTraceEvent) |
129 | | -.filter((event) => event.sessionId === sessionId); |
| 124 | +const events: CacheTraceEvent[] = []; |
| 125 | +for (const rawLine of raw.split("\n")) { |
| 126 | +const line = rawLine.trim(); |
| 127 | +if (line.length > 0) { |
| 128 | +const event = JSON.parse(line) as CacheTraceEvent; |
| 129 | +if (event.sessionId === sessionId) { |
| 130 | +events.push(event); |
| 131 | +} |
| 132 | +} |
| 133 | +} |
| 134 | +return events; |
130 | 135 | } |
131 | 136 | |
132 | 137 | async function expectCacheTraceStages( |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。