From 1c294fd130a68e4ef225646303ea2c4e8e01b702 Mon Sep 17 00:00:00 2001 From: Robert Craigie Date: Fri, 20 Dec 2024 21:05:04 +0000 Subject: [PATCH] fix: abort error handling --- src/lib/EventStream.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/EventStream.ts b/src/lib/EventStream.ts index d3f485e9d..d1b1cc8d3 100644 --- a/src/lib/EventStream.ts +++ b/src/lib/EventStream.ts @@ -1,3 +1,4 @@ +import { isAbortError } from '../internal/errors'; import { APIUserAbortError, OpenAIError } from '../error'; export class EventStream { @@ -145,7 +146,7 @@ export class EventStream { #handleError(this: EventStream, error: unknown) { this.#errored = true; - if (error instanceof Error && error.name === 'AbortError') { + if (isAbortError(error)) { error = new APIUserAbortError(); } if (error instanceof APIUserAbortError) {