MCPcopy Create free account
hub / github.com/firebase/firebase-tools / withTimeout

Function withTimeout

src/utils.ts:450–464  ·  view source on GitHub ↗
(timeoutMs: number, promise: Promise<T>)

Source from the content-addressed store, hash-verified

448 * @return a promise wrapping the original promise with rejection on timeout
449 */
450export function withTimeout<T>(timeoutMs: number, promise: Promise<T>): Promise<T> {
451 return new Promise<T>((resolve, reject) => {
452 const timeout = setTimeout(() => reject(new Error("Timed out.")), timeoutMs);
453 promise.then(
454 (value) => {
455 clearTimeout(timeout);
456 resolve(value);
457 },
458 (err) => {
459 clearTimeout(timeout);
460 reject(err);
461 },
462 );
463 });
464}
465
466/**
467 * Resolves all Promises at every key in the given object. If a value is not a

Callers 1

registerMethod · 0.90

Calls 2

resolveFunction · 0.85
rejectFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…