MCPcopy Create free account
hub / github.com/wonderwhy-er/DesktopCommanderMCP / currentFetchPattern

Function currentFetchPattern

test/test-feature-flags-timeout.js:96–114  ·  view source on GitHub ↗
(url)

Source from the content-addressed store, hash-verified

94const FETCH_TIMEOUT_MS = 3000;
95
96async function currentFetchPattern(url) {
97 const controller = new AbortController();
98 const abortTimeout = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
99 const fetchPromise = fetch(url, {
100 signal: controller.signal,
101 headers: { 'Cache-Control': 'no-cache' },
102 });
103 const hardTimeout = new Promise((_, reject) =>
104 setTimeout(() => reject(new Error('Feature flags fetch timed out')), FETCH_TIMEOUT_MS)
105 );
106 try {
107 const response = await Promise.race([fetchPromise, hardTimeout]);
108 clearTimeout(abortTimeout);
109 return response;
110 } catch (err) {
111 clearTimeout(abortTimeout);
112 throw err;
113 }
114}
115
116// (fixedFetchPattern removed — currentFetchPattern already uses Promise.race)
117

Callers 3

Calls

no outgoing calls

Tested by

no test coverage detected