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

Function waitFor

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

Source from the content-addressed store, hash-verified

167}
168
169async function waitFor(
170 received: Record<string, unknown>[],
171 pred: (f: Record<string, unknown>) => boolean,
172 timeoutMs = 2000,
173): Promise<Record<string, unknown>> {
174 const start = Date.now();
175 while (Date.now() - start < timeoutMs) {
176 const hit = received.find(pred);
177 if (hit !== undefined) return hit;
178 await new Promise((r) => setTimeout(r, 10));
179 }
180 throw new Error(
181 `waitFor timed out; received: ${received.map((f) => f['type']).join(', ')}`,
182 );
183}
184
185describe('WS abort control message (W7.3 / Chain 4b)', () => {
186 it('on first abort: ack with aborted:true + broadcast prompt.aborted', async () => {

Callers 2

openSubscriberFunction · 0.70

Calls 1

nowMethod · 0.65

Tested by

no test coverage detected