Skip to content

Commit

Permalink
feat: allow a default timeout to be set for clients (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot authored and cleb11 committed Aug 15, 2023
1 parent c091449 commit 5403497
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,13 @@ await modernTreasury.externalAccounts.list({

### Timeouts

Requests time out after 60 seconds by default. You can configure this with a `timeout` option:
Requests time out after 1 minute by default. You can configure this with a `timeout` option:

<!-- prettier-ignore -->
```ts
// Configure the default for all requests:
const modernTreasury = new ModernTreasury({
timeout: 20 * 1000, // 20 seconds (default is 60s)
timeout: 20 * 1000, // 20 seconds (default is 1 minute)
organizationId: 'my-organization-ID',
});

Expand Down
2 changes: 1 addition & 1 deletion src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export abstract class APIClient {
constructor({
baseURL,
maxRetries,
timeout = 60 * 1000, // 60s
timeout = 60000, // 1 minute
httpAgent,
fetch: overridenFetch,
}: {
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class ModernTreasury extends Core.APIClient {

super({
baseURL: options.baseURL!,
timeout: options.timeout,
timeout: options.timeout ?? 60000 /* 1 minute */,
httpAgent: options.httpAgent,
maxRetries: options.maxRetries,
fetch: options.fetch,
Expand Down

0 comments on commit 5403497

Please sign in to comment.