MCPcopy
hub / github.com/marimo-team/marimo / waitForNoError

Function waitForNoError

frontend/src/core/islands/__tests__/test-utils.tsx:129–146  ·  view source on GitHub ↗
(
  fn: () => T | Promise<T>,
  timeout = 1000,
)

Source from the content-addressed store, hash-verified

127 * Waits for an async function to not throw
128 */
129export async function waitForNoError<T>(
130 fn: () => T | Promise<T>,
131 timeout = 1000,
132): Promise<T> {
133 const startTime = Date.now();
134 let lastError: Error | undefined;
135
136 while (Date.now() - startTime < timeout) {
137 try {
138 return await Promise.resolve(fn());
139 } catch (error) {
140 lastError = error as Error;
141 await new Promise((resolve) => setTimeout(resolve, 50));
142 }
143 }
144
145 throw lastError || new Error("Timeout waiting for function to succeed");
146}
147
148// ============================================================================
149// HTML-based Island Harness

Callers

nothing calls this directly

Calls 3

fnFunction · 0.50
nowMethod · 0.45
resolveMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…