MCPcopy Create free account
hub / github.com/github/copilot-sdk / withTimeout

Function withTimeout

nodejs/test/e2e/client_lifecycle.e2e.test.ts:20–32  ·  view source on GitHub ↗
(promise: Promise<T>, ms: number, label: string)

Source from the content-addressed store, hash-verified

18 }
19
20 async function withTimeout<T>(promise: Promise<T>, ms: number, label: string): Promise<T> {
21 let timer: NodeJS.Timeout | undefined;
22 try {
23 return await Promise.race([
24 promise,
25 new Promise<T>((_, reject) => {
26 timer = setTimeout(() => reject(new Error(`Timeout: ${label}`)), ms);
27 }),
28 ]);
29 } finally {
30 if (timer) clearTimeout(timer);
31 }
32 }
33
34 it("should return last session id after sending a message", async () => {
35 const session = await client.createSession({ onPermissionRequest: approveAll });

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…