Skip to content

Commit

Permalink
Display warning only once
Browse files Browse the repository at this point in the history
  • Loading branch information
msujew committed Aug 12, 2024
1 parent 8ac4717 commit e435dbc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion dev-packages/ovsx-client/src/ovsx-http-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,18 @@ export class OVSXHttpClient implements OVSXClient {

protected async requestJson<R>(url: string): Promise<R> {
const attempts = 5;
let warn = true;
for (let i = 0; i < attempts; i++) {
await this.rateLimiter.removeTokens(i + 1);
const context = await this.requestService.request({
url,
headers: { 'Accept': 'application/json' }
});
if (context.res.statusCode === 429) {
console.warn('OVSX rate limit exceeded. Will perform request with higher timeout. Consider reducing the rate limit.');
if (warn) {
warn = false;
console.warn('OVSX rate limit exceeded. Will perform request with higher timeout. Consider reducing the rate limit.');
}
if (i < attempts - 1) {
continue;
}
Expand Down

0 comments on commit e435dbc

Please sign in to comment.