MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / waitForEvent

Function waitForEvent

packages/server/test/ws-handshake.e2e.test.ts:47–61  ·  view source on GitHub ↗
(
  records: readonly TelemetryRecord[],
  event: string,
  timeoutMs: number,
)

Source from the content-addressed store, hash-verified

45}
46
47async function waitForEvent(
48 records: readonly TelemetryRecord[],
49 event: string,
50 timeoutMs: number,
51): Promise<TelemetryRecord> {
52 const deadline = Date.now() + timeoutMs;
53 while (Date.now() < deadline) {
54 const found = records.find((r) => r.event === event);
55 if (found !== undefined) return found;
56 await new Promise((res) => {
57 setTimeout(res, 10);
58 });
59 }
60 throw new Error(`event ${event} not observed; got ${JSON.stringify(records)}`);
61}
62
63let tmpDir: string;
64let lockPath: string;

Callers 1

Calls 1

nowMethod · 0.65

Tested by

no test coverage detected