MCPcopy Index your code
hub / github.com/codeaashu/claude-code / withTimeout

Function withTimeout

src/services/lsp/LSPServerInstance.ts:499–511  ·  view source on GitHub ↗

* Race a promise against a timeout. Cleans up the timer regardless of outcome * to avoid unhandled rejections from orphaned setTimeout callbacks.

(
  promise: Promise<T>,
  ms: number,
  message: string,
)

Source from the content-addressed store, hash-verified

497 * to avoid unhandled rejections from orphaned setTimeout callbacks.
498 */
499function withTimeout<T>(
500 promise: Promise<T>,
501 ms: number,
502 message: string,
503): Promise<T> {
504 let timer: ReturnType<typeof setTimeout>
505 const timeoutPromise = new Promise<never>((_, reject) => {
506 timer = setTimeout((rej, msg) => rej(new Error(msg)), ms, reject, message)
507 })
508 return Promise.race([promise, timeoutPromise]).finally(() =>
509 clearTimeout(timer!),
510 )
511}
512

Callers 1

startFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected