Skip to content

Commit

Permalink
fix: abort error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertCraigie committed Dec 20, 2024
1 parent a894cf0 commit 1c294fd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/lib/EventStream.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { isAbortError } from '../internal/errors';
import { APIUserAbortError, OpenAIError } from '../error';

export class EventStream<EventTypes extends BaseEvents> {
Expand Down Expand Up @@ -145,7 +146,7 @@ export class EventStream<EventTypes extends BaseEvents> {

#handleError(this: EventStream<EventTypes>, error: unknown) {
this.#errored = true;
if (error instanceof Error && error.name === 'AbortError') {
if (isAbortError(error)) {
error = new APIUserAbortError();
}
if (error instanceof APIUserAbortError) {
Expand Down

0 comments on commit 1c294fd

Please sign in to comment.