withTimeout function infrastructure ~ 75.0%

Last updated: 2026-03-05T10:53:28.866Z

Metrics

LOC: 10 Complexity: 1 Params: 2 Coverage: 75.0% (3/4 lines, 0x executed)

Signature

withTimeout(promise: Promise<T>, ms: number): : Promise<T>

Source Code

async function withTimeout<T>(promise: Promise<T>, ms: number): Promise<T> {
  let timer: ReturnType<typeof setTimeout>;
  const timeout = new Promise<never>((_, reject) => {
    timer = setTimeout(
      () => reject(new Error(`Storage write timeout (${ms}ms)`)),
      ms,
    );
  });
  return Promise.race([promise, timeout]).finally(() => clearTimeout(timer));
}

No outgoing dependencies.

Impact (Incoming)

graph LR withTimeout["withTimeout"] updateStorageAtomically["updateStorageAtomically"] updateStorageAtomically -->|calls| withTimeout style withTimeout fill:#dbeafe,stroke:#2563eb,stroke-width:2px click withTimeout "fc7affbaf585b37b.html" click updateStorageAtomically "bf2f57323401fa98.html"
SourceType
updateStorageAtomically calls