Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
liangfung committed Dec 31, 2024
1 parent e0f75f6 commit 900e3ee
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions clients/tabby-agent/src/http/tabbyApiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,6 @@ export class TabbyApiClient extends EventEmitter {
canceled: false,
timeout: false,
notAvailable: false,
rateLimited: false,
};

try {
Expand All @@ -385,6 +384,7 @@ export class TabbyApiClient extends EventEmitter {
}
this.logger.trace(`Completion response data: [${requestId}]`, response.data);
statsData.latency = performance.now() - requestStartedAt;
this.updateIsRateLimited(false);
return response.data;
} catch (error) {
this.updateIsFetchingCompletion(false);
Expand All @@ -397,20 +397,20 @@ export class TabbyApiClient extends EventEmitter {
} else if (isUnauthorizedError(error)) {
this.logger.debug(`Completion request failed due to unauthorized. [${requestId}]`);
statsData.notAvailable = true;
this.updateIsRateLimited(false);
this.connect(); // schedule a reconnection
} else if (isRateLimitedError(error)) {
this.logger.debug(`Completion request failed due to rate limiting. [${requestId}]`);
statsData.rateLimited = true;
statsData.notAvailable = true;
this.updateIsRateLimited(true)
} else {
this.logger.error(`Completion request failed. [${requestId}]`, error);
statsData.notAvailable = true;
this.updateIsRateLimited(false);
this.connect(); // schedule a reconnection
}
throw error; // rethrow error
} finally {
this.updateIsRateLimited(statsData.rateLimited);

if (!statsData.notAvailable) {
stats?.addRequestStatsEntry(statsData);
}
Expand Down

0 comments on commit 900e3ee

Please sign in to comment.