@kkdev92/vscode-ext-kit - v4.1.1
    Preparing search index...

    Function withTimeout

    • Races work against a timeout.

      Rejects with TimeoutError if ms elapses first, or with the external signal's reason if that aborts first. A function-form operation receives a signal that aborts on either, so cancellable work stops promptly instead of merely having its result ignored.

      A plain promise cannot be cancelled: timeout only stops waiting for its result. Prefer the function form for I/O or mutations that accept a signal.

      Type Parameters

      • T

      Parameters

      Returns Promise<T>

      const data = await withTimeout(fetchData(url), 5000);
      const response = await withTimeout((signal) => fetch(url, { signal }), 5000);