MCPcopy
hub / github.com/remix-run/react-router / withTimeout

Function withTimeout

packages/react-router-node/__tests__/stream-test.ts:37–46  ·  view source on GitHub ↗
(promise: Promise<T>, ms: number)

Source from the content-addressed store, hash-verified

35}
36
37function withTimeout<T>(promise: Promise<T>, ms: number): Promise<T> {
38 let timeout: ReturnType<typeof setTimeout>;
39 let timeoutPromise = new Promise<never>((_, reject) => {
40 timeout = setTimeout(() => reject(new Error("Timed out")), ms);
41 });
42
43 return Promise.race([promise, timeoutPromise]).finally(() =>
44 clearTimeout(timeout),
45 );
46}
47
48describe("writeReadableStreamToWritable", () => {
49 it("respects writable backpressure", async () => {

Callers 1

stream-test.tsFile · 0.85

Calls 2

raceMethod · 0.80
rejectFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…