diff --git a/libs/client/package.json b/libs/client/package.json index 5a2f8f3..80bf2d9 100644 --- a/libs/client/package.json +++ b/libs/client/package.json @@ -1,7 +1,7 @@ { "name": "@fal-ai/client", "description": "The fal.ai client for JavaScript and TypeScript", - "version": "1.0.2", + "version": "1.0.3", "license": "MIT", "repository": { "type": "git", diff --git a/libs/client/src/index.ts b/libs/client/src/index.ts index e76efa3..18554fb 100644 --- a/libs/client/src/index.ts +++ b/libs/client/src/index.ts @@ -11,7 +11,7 @@ export type { RealtimeClient } from "./realtime"; export { ApiError, ValidationError } from "./response"; export type { ResponseHandler } from "./response"; export type { StorageClient } from "./storage"; -export type { StreamingClient } from "./streaming"; +export type { FalStream, StreamingClient } from "./streaming"; export * from "./types"; export type { QueueStatus, diff --git a/libs/client/src/streaming.ts b/libs/client/src/streaming.ts index ebfe5dd..c23001b 100644 --- a/libs/client/src/streaming.ts +++ b/libs/client/src/streaming.ts @@ -265,6 +265,13 @@ export class FalStream { }; private handleError = (error: any) => { + // In case AbortError is thrown but the signal is marked as aborted + // it means the user called abort() and we should not emit an error + // as it's expected behavior + // See note on: https://developer.mozilla.org/en-US/docs/Web/API/AbortController/abort + if (this.signal.aborted) { + return; + } const apiError = error instanceof ApiError ? error @@ -325,6 +332,15 @@ export class FalStream { public abort = () => { this.abortController.abort(); }; + + /** + * Gets the `AbortSignal` instance that can be used to listen for abort events. + * @returns the `AbortSignal` instance. + * @see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal + */ + public get signal() { + return this.abortController.signal; + } } /**