Skip to content

armgit / orca

Public Imported from GitHub
0

Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

784 B
Raw Blame
export type DiagnosticFetchTimeout = {
  readonly signal: AbortSignal
  readonly timedOut: boolean
  dispose: () => void
}

export function startDiagnosticFetchTimeout(timeoutMs: number): DiagnosticFetchTimeout {
  const controller = new AbortController()
  let disposed = false
  let timedOut = false
  let timer: ReturnType<typeof setTimeout> | null = setTimeout(() => {
    timer = null
    timedOut = true
    controller.abort()
  }, timeoutMs)

  function dispose() {
    if (disposed) {
      return
    }
    disposed = true
    if (timer) {
      clearTimeout(timer)
      timer = null
    }
    if (!controller.signal.aborted) {
      controller.abort()
    }
  }

  return {
    signal: controller.signal,
    get timedOut() {
      return timedOut
    },
    dispose
  }
}