Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve caller abort forwarding until body is consumed

Removing the caller-signal listener in fetchWithTimeout's finally detaches cancellation as soon as fetch() resolves (headers received), but this client parses/streams the body afterward via the same controller (see makeRequest returning response and defaultParseResponse consuming it later). In that window, aborting the user-provided signal no longer propagates, so long JSON reads or SSE streams can continue running even though the caller explicitly cancelled.

Useful? React with 👍 / 👎.

}
}

Expand Down