Skip to content

Commit a0bac18

Browse files
fix: remove abort event listener on successful completion in fetchWithTimeout
When an AbortSignal is passed to fetchWithTimeout, the method adds an event listener to forward abort events to the internal controller but never removes it on successful completion. In Deno, this refs the underlying timer of AbortSignal.timeout(), preventing the process from exiting until the full timeout duration elapses. Fixes #1811
1 parent 35feb53 commit a0bac18

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

src/client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,7 @@ export class OpenAI {
892892
return await this.fetch.call(undefined, url, fetchOptions);
893893
} finally {
894894
clearTimeout(timeout);
895+
if (signal) signal.removeEventListener('abort', abort);
895896
}
896897
}
897898

0 commit comments

Comments
 (0)