@pulumi/cloud-sdk - v2026.10.9
    Preparing search index...

    Class CancelSignal

    Caller-side cancellation primitive for Promise<T> / Future<T>-shaped APIs.

    guard(p) returns a promise that adopts p's settlement unless cancel() fires first, in which case it rejects with DOMException("...", "AbortError").

    The behavior depends on the input:

    • Future<T> (the runtime shape returned by every apis.* method): on cancel, guard rejects the Future directly. ApiClient.callWithOptions observes that rejection and aborts the underlying fetch, so the request is dropped on the wire.

    • plain Promise<T>: Promise.race against the cancel signal. The underlying work keeps running and the result is read but unobserved.

    Per-operation signals (search-as-you-type debounce, "stop loading" buttons) construct their own CancelSignal instances and call cancel() directly.

    Index
    • Expose the underlying cancel promise for code that needs to observe cancellation directly. The returned promise rejects with the cancel error and never resolves.

      Returns Promise<never>

    • Reject all pending and future guard()s on this signal with DOMException(reason, "AbortError"). Idempotent: subsequent calls are silent no-ops, so callers can safely cancel a signal that may already have been cancelled.

      Parameters

      • Optionalreason: string

      Returns void

    • Race p against this signal. If p is a Future, drive cancellation by rejecting the Future on cancel() — that propagates through the API client to abort the wire request. Otherwise fall back to Promise.race (the work keeps running unobserved).

      If cancel() is called after the input already settled, the resolved value flows through unchanged: Future.reject is idempotent post-settle, and Promise.race only honors the first settlement.

      Type Parameters

      • T

      Parameters

      Returns Promise<T>