Skip to content

AbortSignal

Namespace: Vercel.AI.Util

public sealed class AbortSignal

Abort signal that records the first reason.

Inheritance: object

View source

public bool Aborted { get; }

Whether Abort(object) has been called.

Value: bool

View source

public object? Reason { get; }

Reason passed to the abort that won.

Value: object

View source

public void Abort(object? reason)

Aborts unless this signal is already aborted. Every handler runs, even when an earlier one throws. The first handler exception is rethrown after the last handler ran.

Parameters

Name Type Description
reason object

View source

public void AddAbortHandler(Action handler)

Runs <code class=“paramref”>handler</code> when aborted. Runs immediately if already aborted.

Parameters

Name Type Description
handler Action

View source

public void RemoveAbortHandler(Action handler)

Removes a handler added by AddAbortHandler(Action).

Parameters

Name Type Description
handler Action

View source

public static AbortSignal Timeout(int timeoutMs, Action<Action, int>? schedule = null)

Signal that aborts with TimeoutError after <code class=“paramref”>timeoutMs</code>.

Parameters

Name Type Description
timeoutMs int
schedule Action<Action, int>

Returns: AbortSignal

View source

Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product