Skip to content

isAbortError

isAbortError(error): boolean

Defined in: core/errors.ts:37

Detects if an error is an abort/cancellation error from any provider.

Different providers throw different error types when a request is aborted:

  • Standard: AbortError (name) - from fetch/AbortController
  • Anthropic SDK: APIConnectionAbortedError
  • OpenAI SDK: APIUserAbortError
  • Generic: errors with “abort”, “cancelled”, or “canceled” in the message

unknown

The error to check

boolean

true if the error is an abort-related error, false otherwise

import { isAbortError } from "@llmist/core/errors";
const controller = new AbortController();
try {
for await (const chunk of client.stream({ signal: controller.signal, ... })) {
// Process chunks...
}
} catch (error) {
if (isAbortError(error)) {
console.log("Request was cancelled - this is expected");
return; // Graceful exit
}
// Re-throw unexpected errors
throw error;
}