MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / waitFor

Function waitFor

apps/vscode-e2e/src/suite/utils.ts:8–40  ·  view source on GitHub ↗
(
	condition: (() => Promise<boolean>) | (() => boolean),
	{ timeout = 30_000, interval = 250 }: WaitForOptions = {},
)

Source from the content-addressed store, hash-verified

6}
7
8export const waitFor = (
9 condition: (() => Promise<boolean>) | (() => boolean),
10 { timeout = 30_000, interval = 250 }: WaitForOptions = {},
11) => {
12 let timeoutId: NodeJS.Timeout | undefined = undefined
13
14 return Promise.race([
15 new Promise<void>((resolve) => {
16 const check = async () => {
17 const result = condition()
18 const isSatisfied = result instanceof Promise ? await result : result
19
20 if (isSatisfied) {
21 if (timeoutId) {
22 clearTimeout(timeoutId)
23 timeoutId = undefined
24 }
25
26 resolve()
27 } else {
28 setTimeout(check, interval)
29 }
30 }
31
32 check()
33 }),
34 new Promise((_, reject) => {
35 timeoutId = setTimeout(() => {
36 reject(new Error(`Timeout after ${Math.floor(timeout / 1000)}s`))
37 }, timeout)
38 }),
39 ])
40}
41
42type WaitUntilAbortedOptions = WaitForOptions & {
43 api: RooCodeAPI

Callers 15

subtasks.test.tsFile · 0.90
runFunction · 0.90
mcp-oauth.test.tsFile · 0.90
ensureOAuthTokenCachedFunction · 0.90
read-file.test.tsFile · 0.90
runMcpTaskFunction · 0.90
list-files.test.tsFile · 0.90
runXAIToolProbeFunction · 0.90
runDeepSeekToolProbeFunction · 0.90
waitUntilAbortedFunction · 0.85

Calls 1

checkFunction · 0.85

Tested by 6

ensureOAuthTokenCachedFunction · 0.72
runMcpTaskFunction · 0.72
runXAIToolProbeFunction · 0.72
runDeepSeekToolProbeFunction · 0.72
waitForOpenHandlerFunction · 0.68