Skip to content

Commit d330c2f

Browse files
authored
test(utils): Add test for global rate limit response with scope (#7631)
Add a small test to check if the SDK parses a rate limit response that has no category but a scope: `60::organization`. This came up in Slack and in getsentry/ops#6446 (comment).
1 parent 7d080dc commit d330c2f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

packages/utils/test/ratelimit.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,14 @@ describe('updateRateLimits()', () => {
186186
const updatedRateLimits = updateRateLimits(rateLimits, { statusCode: 200 }, 0);
187187
expect(updatedRateLimits).toEqual(rateLimits);
188188
});
189+
190+
test('should apply a global rate limit with a scope on a 429 status code', () => {
191+
const rateLimits: RateLimits = {};
192+
const headers = {
193+
'retry-after': null,
194+
'x-sentry-rate-limits': '60::organization',
195+
};
196+
const updatedRateLimits = updateRateLimits(rateLimits, { statusCode: 429, headers }, 0);
197+
expect(updatedRateLimits.all).toEqual(60_000);
198+
});
189199
});

0 commit comments

Comments
 (0)