MCPcopy Create free account
hub / github.com/dailydotdev/apps / fetchTimeout

Function fetchTimeout

packages/shared/src/lib/fetchTimeout.ts:1–13  ·  view source on GitHub ↗
(
  url: string,
  ms: number,
  { signal, ...options }: RequestInit = {},
)

Source from the content-addressed store, hash-verified

1export default function fetchTimeout(
2 url: string,
3 ms: number,
4 { signal, ...options }: RequestInit = {},
5): Promise<Response> {
6 const controller = new AbortController();
7 const promise = fetch(url, { signal: controller.signal, ...options });
8 if (signal) {
9 signal.addEventListener('abort', () => controller.abort());
10 }
11 const timeout = setTimeout(() => controller.abort(), ms);
12 return promise.finally(() => clearTimeout(timeout));
13}

Callers 1

NewSourceModalFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected