Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: 2.32.1 #480

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "2.32.0"
".": "2.32.1"
}
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 2.32.1 (2024-10-18)

Full Changelog: [v2.32.0...v2.32.1](https://github.com/Modern-Treasury/modern-treasury-node/compare/v2.32.0...v2.32.1)

### Bug Fixes

* **client:** respect x-stainless-retry-count default headers ([#479](https://github.com/Modern-Treasury/modern-treasury-node/issues/479)) ([583a4f9](https://github.com/Modern-Treasury/modern-treasury-node/commit/583a4f9996339255506574f2bd918c621b94b22d))

## 2.32.0 (2024-10-16)

Full Changelog: [v2.31.1...v2.32.0](https://github.com/Modern-Treasury/modern-treasury-node/compare/v2.31.1...v2.32.0)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "modern-treasury",
"version": "2.32.0",
"version": "2.32.1",
"description": "The official TypeScript library for the Modern Treasury API",
"author": "Modern Treasury <sdk-feedback@moderntreasury.com>",
"types": "dist/index.d.ts",
Expand Down
10 changes: 7 additions & 3 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,13 @@ export abstract class APIClient {
delete reqHeaders['content-type'];
}

// Don't set the retry count header if it was already set or removed by the caller. We check `headers`,
// which can contain nulls, instead of `reqHeaders` to account for the removal case.
if (getHeader(headers, 'x-stainless-retry-count') === undefined) {
// Don't set the retry count header if it was already set or removed through default headers or by the
// caller. We check `defaultHeaders` and `headers`, which can contain nulls, instead of `reqHeaders` to
// account for the removal case.
if (
getHeader(defaultHeaders, 'x-stainless-retry-count') === undefined &&
getHeader(headers, 'x-stainless-retry-count') === undefined
) {
reqHeaders['x-stainless-retry-count'] = String(retryCount);
}

Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '2.32.0'; // x-release-please-version
export const VERSION = '2.32.1'; // x-release-please-version
34 changes: 34 additions & 0 deletions tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,40 @@ describe('retries', () => {
expect(capturedRequest!.headers as Headers).not.toHaveProperty('x-stainless-retry-count');
});

test('omit retry count header by default', async () => {
let count = 0;
let capturedRequest: RequestInit | undefined;
const testFetch = async (url: RequestInfo, init: RequestInit = {}): Promise<Response> => {
count++;
if (count <= 2) {
return new Response(undefined, {
status: 429,
headers: {
'Retry-After': '0.1',
},
});
}
capturedRequest = init;
return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } });
};
const client = new ModernTreasury({
apiKey: 'My API Key',
organizationId: 'my-organization-ID',
fetch: testFetch,
maxRetries: 4,
defaultHeaders: { 'X-Stainless-Retry-Count': null },
});

expect(
await client.request({
path: '/foo',
method: 'get',
}),
).toEqual({ a: 1 });

expect(capturedRequest!.headers as Headers).not.toHaveProperty('x-stainless-retry-count');
});

test('overwrite retry count header', async () => {
let count = 0;
let capturedRequest: RequestInit | undefined;
Expand Down