MCPcopy
hub / github.com/callumalpass/tasknotes / createRequest

Method createRequest

src/utils/RequestDeduplicator.ts:33–54  ·  view source on GitHub ↗

* Create and manage a request with cleanup

(
		key: string,
		requestFn: () => Promise<T>,
		ttl: number
	)

Source from the content-addressed store, hash-verified

31 * Create and manage a request with cleanup
32 */
33 private async createRequest<T>(
34 key: string,
35 requestFn: () => Promise<T>,
36 ttl: number
37 ): Promise<T> {
38 try {
39 const result = await requestFn();
40
41 // Schedule cleanup after TTL
42 const timeout = window.setTimeout(() => {
43 this.inFlightRequests.delete(key);
44 this.activeTimeouts.delete(timeout);
45 }, ttl);
46 this.activeTimeouts.add(timeout);
47
48 return result;
49 } catch (error) {
50 // Remove failed request immediately
51 this.inFlightRequests.delete(key);
52 throw error;
53 }
54 }
55
56 /**
57 * Prefetch data that might be needed soon

Callers 1

executeMethod · 0.95

Calls 2

setTimeoutMethod · 0.65
deleteMethod · 0.65

Tested by

no test coverage detected