withTimeout function infrastructure ~ 75.0%
Last updated: 2026-03-05T10:53:28.866Z
Location
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)
| Source | Type |
|---|---|
| updateStorageAtomically | calls |