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

Method waitForId

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

Source from the content-addressed store, hash-verified

101 }
102
103 waitForId(id: JsonRpcId, timeoutMs: number): Promise<JsonRpcMessage> {
104 const existing = this.messages.find((message) => message.id === id);
105 if (existing) return Promise.resolve(existing);
106 return new Promise((resolve, reject) => {
107 const timeout = setTimeout(() => {
108 // oxlint-disable-next-line executor/no-promise-reject, executor/no-error-constructor -- boundary: Promise timeout adapter for e2e polling.
109 reject(new Error(`timed out waiting for JSON-RPC id ${id}`));
110 }, timeoutMs);
111 const waiter = {
112 resolve: (message: JsonRpcMessage) => {
113 clearTimeout(timeout);
114 resolve(message);
115 },
116 };
117 this.waiters.set(id, [...(this.waiters.get(id) ?? []), waiter]);
118 });
119 }
120
121 waitForFirstResponse(timeoutMs: number): Promise<JsonRpcMessage> {
122 const existing = this.messages.find(

Callers 1

Calls 5

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

Tested by

no test coverage detected