MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / waitFor

Function waitFor

console/src/test/sql/waitFor.ts:14–30  ·  view source on GitHub ↗
(fn: () => Promise<unknown>, timeout = 3000)

Source from the content-addressed store, hash-verified

12 * ellapsed timeout.
13 */
14export async function waitFor(fn: () => Promise<unknown>, timeout = 3000) {
15 const start = performance.now();
16 let finished = false;
17 while (!finished) {
18 try {
19 await fn();
20 return;
21 } catch (e) {
22 const elapsed = performance.now() - start;
23 if (elapsed >= timeout) {
24 finished = true;
25 console.error(`waitFor timed out after ${timeout}ms`);
26 throw e;
27 }
28 }
29 }
30}

Calls 3

fnFunction · 0.85
nowMethod · 0.45
errorMethod · 0.45

Tested by 1