MCPcopy Create free account
hub / github.com/getsentry/sentry-javascript / withTimeout

Function withTimeout

packages/deno/test/deno-redis.test.ts:47–55  ·  view source on GitHub ↗
(p: Promise<T>, ms: number, what: string)

Source from the content-addressed store, hash-verified

45}
46
47function withTimeout<T>(p: Promise<T>, ms: number, what: string): Promise<T> {
48 let timer: ReturnType<typeof setTimeout> | undefined;
49 const timeout = new Promise<T>((_, reject) => {
50 timer = setTimeout(() => reject(new Error(`Timed out waiting for ${what} after ${ms}ms`)), ms);
51 });
52 return Promise.race([p, timeout]).finally(() => {
53 if (timer !== undefined) clearTimeout(timer);
54 });
55}
56
57Deno.test('denoRedisIntegration: included in default integrations', () => {
58 resetGlobals();

Callers 1

deno-redis.test.tsFile · 0.70

Calls 2

setTimeoutFunction · 0.85
finallyMethod · 0.65

Tested by

no test coverage detected