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

Function runWithTimeout

src/tools/REPLTool/javascriptReplFactory.tsx:298–317  ·  view source on GitHub ↗
(
  promise: Promise<T>,
  timeoutMs: number,
)

Source from the content-addressed store, hash-verified

296}
297
298async function runWithTimeout<T>(
299 promise: Promise<T>,
300 timeoutMs: number,
301): Promise<T> {
302 return await new Promise<T>((resolve, reject) => {
303 const timeout = setTimeout(() => {
304 reject(new Error(`JavaScript REPL execution timed out after ${timeoutMs}ms`))
305 }, timeoutMs)
306 promise.then(
307 value => {
308 clearTimeout(timeout)
309 resolve(value)
310 },
311 error => {
312 clearTimeout(timeout)
313 reject(error)
314 },
315 )
316 })
317}
318
319function formatToolCallSummary(call: ReplToolCallSummary): string {
320 const input = preview(stringifyUnknown(call.toolInput))

Callers 1

callFunction · 0.85

Calls 1

resolveFunction · 0.50

Tested by

no test coverage detected