MCPcopy Index your code
hub / github.com/mailvelope/mailvelope / withTimeout

Function withTimeout

test/unit/modules/defaults.test.js:11–21  ·  view source on GitHub ↗
(promise, label, ms = STARTUP_TIMEOUT_MS)

Source from the content-addressed store, hash-verified

9const STARTUP_TIMEOUT_MS = 500;
10
11async function withTimeout(promise, label, ms = STARTUP_TIMEOUT_MS) {
12 let timer;
13 const guard = new Promise((_, reject) => {
14 timer = setTimeout(() => reject(new Error(`${label}: startup chain hung > ${ms}ms`)), ms);
15 });
16 try {
17 return await Promise.race([promise, guard]);
18 } finally {
19 clearTimeout(timer);
20 }
21}
22
23// Wire chrome.storage.local.get/set against a plain object so each test can
24// pre-seed state and observe writes. The default mock in service-worker-env.js

Callers 1

defaults.test.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected