Skip to content

Commit

Permalink
feat(streaming): make requests immediately throw an error if an abort…
Browse files Browse the repository at this point in the history
…ed signal is passed in (#79)
  • Loading branch information
stainless-bot authored and rattrayalex committed Jul 22, 2023
1 parent caae87d commit 5c86597
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/core.ts
Expand Up @@ -208,6 +208,10 @@ export abstract class APIClient {

this.debug('request', url, options, req.headers);

if (options.signal?.aborted) {
throw new APIUserAbortError();
}

const controller = new AbortController();
const response = await this.fetchWithTimeout(url, req, timeout, controller).catch(castToError);

Expand Down

0 comments on commit 5c86597

Please sign in to comment.