MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / waitFor

Method waitFor

__tests__/ui-events-api.test.ts:149–161  ·  view source on GitHub ↗

Wait for an event of `type`, or give up. Never polls the server.

(type: string, timeoutMs = 12_000)

Source from the content-addressed store, hash-verified

147
148 /** Wait for an event of `type`, or give up. Never polls the server. */
149 async waitFor(type: string, timeoutMs = 12_000): Promise<SseEvent> {
150 const deadline = Date.now() + timeoutMs;
151 for (;;) {
152 const hit = this.events.find((e) => e.event === type);
153 if (hit) return hit;
154 if (Date.now() > deadline) {
155 throw new Error(
156 `No "${type}" event within ${timeoutMs}ms. Saw: ${this.events.map((e) => e.event).join(', ') || '(nothing)'}`
157 );
158 }
159 await new Promise((r) => setTimeout(r, 25));
160 }
161 }
162
163 close(): void {
164 this.res?.destroy();

Calls 2

mapMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected