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

Function waitFor

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

Source from the content-addressed store, hash-verified

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

Callers 2

openSubscriberFunction · 0.70

Calls 1

nowMethod · 0.65

Tested by

no test coverage detected