MCPcopy Create free account
hub / github.com/github/copilot-sdk / waitFor

Function waitFor

nodejs/test/e2e/session_lifecycle.e2e.test.ts:14–24  ·  view source on GitHub ↗

* Polls until predicate returns true or deadline expires. Used in lieu of arbitrary * `setTimeout` waits for "session flushed to disk" so fast machines exit immediately * and slow CI machines still get up to `timeoutMs` before the test fails.

(
    predicate: () => Promise<boolean> | boolean,
    timeoutMs = 10_000
)

Source from the content-addressed store, hash-verified

12 * and slow CI machines still get up to `timeoutMs` before the test fails.
13 */
14async function waitFor(
15 predicate: () => Promise<boolean> | boolean,
16 timeoutMs = 10_000
17): Promise<void> {
18 const deadline = Date.now() + timeoutMs;
19 while (Date.now() < deadline) {
20 if (await predicate()) return;
21 await new Promise((r) => setTimeout(r, 50));
22 }
23 throw new Error(`waitFor: condition not met within ${timeoutMs}ms`);
24}
25
26describe("Session Lifecycle", async () => {
27 const { copilotClient: client } = await createSdkTestContext();

Callers 1

Calls 1

predicateFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…