MCPcopy
hub / github.com/callstack/agent-device / sleep

Function sleep

src/utils/retry.ts:190–216  ·  view source on GitHub ↗
(ms: number, signal?: AbortSignal)

Source from the content-addressed store, hash-verified

188}
189
190function sleep(ms: number, signal?: AbortSignal): Promise<void> {
191 return new Promise((resolve) => {
192 if (signal?.aborted) {
193 resolve();
194 return;
195 }
196 let settled = false;
197 const finish = () => {
198 if (settled) return;
199 settled = true;
200 if (signal) {
201 signal.removeEventListener('abort', onAbort);
202 }
203 resolve();
204 };
205 const timer = setTimeout(finish, ms);
206
207 function onAbort(): void {
208 clearTimeout(timer);
209 finish();
210 }
211
212 if (signal) {
213 signal.addEventListener('abort', onAbort, { once: true });
214 }
215 });
216}
217
218function publishRetryEvent(event: RetryTelemetryEvent): void {
219 emitDiagnostic({

Callers 15

waitForStableFileFunction · 0.90
waitForPlayableVideoFunction · 0.90
acquireProcessLockFunction · 0.90
waitForProcessExitFunction · 0.90
waitFunction · 0.90
startAndroidAppLogFunction · 0.90
waitForAndroidAppFocusFunction · 0.90
startLocalDaemonFunction · 0.90
waitForDaemonStartupFunction · 0.90

Calls 1

resolveFunction · 0.70

Tested by

no test coverage detected