Skip to main content
The getAbortSignal() function returns an AbortSignal that automatically aborts when the current $derived or $effect re-runs or is destroyed. This is useful for cancelling ongoing async operations.

Import

Signature

Returns

AbortSignal
AbortSignal
A standard AbortSignal that aborts when the effect re-runs or is destroyed

Usage

Cancelling fetch requests

Cleanup in effects

With intervals

Error handling

Notes

  • Must be called inside a $derived or $effect
  • Each call returns a unique signal
  • The signal aborts automatically on cleanup
  • Works with any API that accepts an AbortSignal
  • Helps prevent race conditions and memory leaks

See also