Logos DX
    Preparing search index...

    Function runWithTimeout

    • Tries to execute a function with a timeout. If the function exceeds the timeout, it will reject with a TimeoutError.

      Type Parameters

      Parameters

      • func: T

        The function to execute

      • opts: WithTimeoutOptions

        Configuration options

        • OptionalabortController?: AbortController

          Abort controller to cancel the operation

        • OptionalonError?: (error: Error, didTimeout: boolean) => void

          Capture errors

        • OptionalonTimeout?: (error: TimeoutError) => void

          On timeout callback

        • Optionalthrows?: boolean

          Rethrow errors

        • timeout: number

          Timeout in milliseconds after which the function will be rejected

      Returns Promise<ReturnType<T> | null>

      The result of the function execution

      When the function execution exceeds the specified timeout