diff --git a/src/client.ts b/src/client.ts index f55a6b986..06a9b81fe 100644 --- a/src/client.ts +++ b/src/client.ts @@ -892,6 +892,11 @@ export class OpenAI { return await this.fetch.call(undefined, url, fetchOptions); } finally { clearTimeout(timeout); + // Remove the forwarding listener so the caller's signal (and any + // underlying timer, e.g. AbortSignal.timeout()) can be GC'd + // immediately. Without this, Deno keeps the timer ref'd for the + // full timeout duration, preventing clean process exit. See #1811. + if (signal) signal.removeEventListener('abort', abort); } }