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

Function waitForCondition

nodejs/test/e2e/harness/sdkTestHelper.ts:130–146  ·  view source on GitHub ↗
(
    predicate: () => boolean | Promise<boolean>,
    {
        timeoutMs = 30_000,
        intervalMs = 100,
        timeoutMessage = "Timed out waiting for condition.",
    }: { timeoutMs?: number; intervalMs?: number; timeoutMessage?: string } = {}
)

Source from the content-addressed store, hash-verified

128}
129
130export async function waitForCondition(
131 predicate: () => boolean | Promise<boolean>,
132 {
133 timeoutMs = 30_000,
134 intervalMs = 100,
135 timeoutMessage = "Timed out waiting for condition.",
136 }: { timeoutMs?: number; intervalMs?: number; timeoutMessage?: string } = {}
137): Promise<void> {
138 const deadline = Date.now() + timeoutMs;
139 while (Date.now() < deadline) {
140 if (await predicate()) {
141 return;
142 }
143 await new Promise((resolve) => setTimeout(resolve, intervalMs));
144 }
145 throw new Error(timeoutMessage);
146}

Calls 1

predicateFunction · 0.85

Tested by 4

waitForMcpServerStatusFunction · 0.72
waitForMcpServerStatusFunction · 0.72
waitForMcpRunningFunction · 0.72
waitForFileExistsFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…