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

Function waitFor

packages/server/test/approval.e2e.test.ts:163–177  ·  view source on GitHub ↗
(
  received: Record<string, unknown>[],
  pred: (f: Record<string, unknown>) => boolean,
  timeoutMs = 2000,
)

Source from the content-addressed store, hash-verified

161}
162
163async function waitFor(
164 received: Record<string, unknown>[],
165 pred: (f: Record<string, unknown>) => boolean,
166 timeoutMs = 2000,
167): Promise<Record<string, unknown>> {
168 const start = Date.now();
169 while (Date.now() - start < timeoutMs) {
170 const hit = received.find(pred);
171 if (hit !== undefined) return hit;
172 await new Promise((r) => setTimeout(r, 10));
173 }
174 throw new Error(
175 `waitFor timed out; received: ${received.map((f) => f['type']).join(', ')}`,
176 );
177}
178
179function firstPendingApprovalId(broker: ApprovalService): string | undefined {
180 return (broker as unknown as {

Callers 2

openSubscriberFunction · 0.70

Calls 1

nowMethod · 0.65

Tested by

no test coverage detected