MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / waitForId

Method waitForId

e2e/cloud/mcp-sse-replay.test.ts:93–109  ·  view source on GitHub ↗
(id: string, timeoutMs: number)

Source from the content-addressed store, hash-verified

91 }
92
93 waitForId(id: string, timeoutMs: number): Promise<JsonRpcMessage> {
94 const existing = this.messages.find((message) => message.id === id);
95 if (existing) return Promise.resolve(existing);
96 return new Promise((resolve, reject) => {
97 const timeout = setTimeout(() => {
98 // oxlint-disable-next-line executor/no-promise-reject, executor/no-error-constructor -- boundary: Promise timeout adapter for e2e polling.
99 reject(new Error(`timed out waiting for JSON-RPC id ${id}`));
100 }, timeoutMs);
101 const waiter = {
102 resolve: (message: JsonRpcMessage) => {
103 clearTimeout(timeout);
104 resolve(message);
105 },
106 };
107 this.waiters.set(id, [...(this.waiters.get(id) ?? []), waiter]);
108 });
109 }
110
111 abort(reason: string): void {
112 this.abortController?.abort(reason);

Callers 1

Calls 5

rejectFunction · 0.85
resolveMethod · 0.80
setMethod · 0.80
getMethod · 0.65
resolveFunction · 0.50

Tested by

no test coverage detected