Skip to content

Commit 1c294fd

Browse files
committed
fix: abort error handling
1 parent a894cf0 commit 1c294fd

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/lib/EventStream.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { isAbortError } from '../internal/errors';
12
import { APIUserAbortError, OpenAIError } from '../error';
23

34
export class EventStream<EventTypes extends BaseEvents> {
@@ -145,7 +146,7 @@ export class EventStream<EventTypes extends BaseEvents> {
145146

146147
#handleError(this: EventStream<EventTypes>, error: unknown) {
147148
this.#errored = true;
148-
if (error instanceof Error && error.name === 'AbortError') {
149+
if (isAbortError(error)) {
149150
error = new APIUserAbortError();
150151
}
151152
if (error instanceof APIUserAbortError) {

0 commit comments

Comments
 (0)