Function waitUntilAborted

  • Race a promise against an AbortSignal. Unlike a plain reject-on-abort race, this resolves with a tagged result so callers can branch on isAborted instead of catching. On abort it resolves { result: undefined, isAborted: true }; otherwise it resolves { result, isAborted: false }. A rejection of the underlying promise is propagated. The abort listener is always cleaned up.

    An already-aborted signal short-circuits immediately to the abort result.

    Note: the underlying promise is not cancelled — it keeps running; this only stops waiting for it. Because the promise is passed already-created, the caller's operation has already started, so a pre-aborted signal won't prevent that side effect (pass/await a factory yourself if you need to avoid starting it).

    Type Parameters

    • T

    Parameters

    • promise: Promise<T>
    • signal: AbortSignal

    Returns Promise<Aborted<T>>