MCPcopy Create free account
hub / github.com/Noumena-Network/code / timeoutPromise

Function timeoutPromise

src/remote/appServer/client.ts:232–246  ·  view source on GitHub ↗
(
  promise: Promise<T>,
  timeoutMs: number,
  message: string,
)

Source from the content-addressed store, hash-verified

230}
231
232function timeoutPromise<T>(
233 promise: Promise<T>,
234 timeoutMs: number,
235 message: string,
236): Promise<T> {
237 let timer: NodeJS.Timeout | undefined
238 const timeout = new Promise<never>((_, reject) => {
239 timer = setTimeout(() => reject(new Error(message)), timeoutMs)
240 })
241 return Promise.race([promise, timeout]).finally(() => {
242 if (timer) {
243 clearTimeout(timer)
244 }
245 })
246}
247
248export class RemoteAppServerClient {
249 private ws: WS | null = null

Callers 2

openMethod · 0.85
initializeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected