MCPcopy Create free account
hub / github.com/apache/maka / within

Function within

packages/runtime/src/__tests__/runtime-kernel-interaction.test.ts:700–712  ·  view source on GitHub ↗
(promise: Promise<T>, operation: string)

Source from the content-addressed store, hash-verified

698}
699
700async function within<T>(promise: Promise<T>, operation: string): Promise<T> {
701 let timeout: NodeJS.Timeout | undefined;
702 try {
703 return await Promise.race([
704 promise,
705 new Promise<T>((_resolve, reject) => {
706 timeout = setTimeout(() => reject(new Error(`${operation} timed out`)), 1_000);
707 }),
708 ]);
709 } finally {
710 if (timeout) clearTimeout(timeout);
711 }
712}

Calls 3

raceMethod · 0.80
setTimeoutFunction · 0.50
clearTimeoutFunction · 0.50

Tested by

no test coverage detected