MCPcopy
hub / github.com/coder/mux / countStaleStepUpdates

Function countStaleStepUpdates

src/node/services/__tests__/devToolsService.test.ts:60–86  ·  view source on GitHub ↗
(logContents: string, stepId: string)

Source from the content-addressed store, hash-verified

58}
59
60function countStaleStepUpdates(logContents: string, stepId: string): number {
61 return logContents.split("\n").reduce((count, line) => {
62 if (!line.trim()) {
63 return count;
64 }
65
66 try {
67 const parsed = JSON.parse(line) as {
68 type?: unknown;
69 stepId?: unknown;
70 update?: { error?: unknown } | null;
71 };
72
73 if (
74 parsed.type === "step-update" &&
75 parsed.stepId === stepId &&
76 parsed.update?.error === "Interrupted (stale)"
77 ) {
78 return count + 1;
79 }
80 } catch {
81 // Ignore malformed test fixture lines while counting stale-step updates.
82 }
83
84 return count;
85 }, 0);
86}
87
88describe("DevToolsService", () => {
89 let tempDir: string;

Callers 1

Calls 1

parseMethod · 0.45

Tested by

no test coverage detected