Skip to content

Commit

Permalink
fix(agent): fix health chck request canceled error handler. (#3457)
Browse files Browse the repository at this point in the history
* fix(agent): fix health chck request canceled error handler.

* fix(agent): fix health chck request canceled error handler.
  • Loading branch information
icycodes authored Nov 22, 2024
1 parent 97e3242 commit 171354e
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions clients/tabby-agent/src/http/tabbyApiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,29 +273,30 @@ export class TabbyApiClient extends EventEmitter {
this.serverHealth = response.data;
this.updateStatus("ready");
} catch (error) {
this.serverHealth = undefined;
if (error instanceof HttpError && error.status == 405 && method !== "POST") {
if (isCanceledError(error)) {
this.logger.debug(`Health check request canceled. [${requestId}]`);
} else if (error instanceof HttpError && error.status == 405 && method !== "POST") {
return await this.healthCheck(signal, "POST");
} else if (isUnauthorizedError(error)) {
this.serverHealth = undefined;
this.updateStatus("unauthorized");
} else if (isTimeoutError(error)) {
this.logger.error(`Health check request timed out. [${requestId}]`, error);
this.serverHealth = undefined;
this.connectionErrorMessage = `${requestDescription} timed out.`;
this.updateStatus("noConnection");
} else {
if (isCanceledError(error)) {
this.logger.debug(`Health check request canceled. [${requestId}]`);
this.connectionErrorMessage = `${requestDescription} canceled.`;
} else if (isTimeoutError(error)) {
this.logger.error(`Health check request timed out. [${requestId}]`, error);
this.connectionErrorMessage = `${requestDescription} timed out.`;
} else {
this.logger.error(`Health check request failed. [${requestId}]`, error);
const message = error instanceof Error ? errorToString(error) : JSON.stringify(error);
this.connectionErrorMessage = `${requestDescription} failed: \n${message}`;
}
this.logger.error(`Health check request failed. [${requestId}]`, error);
this.serverHealth = undefined;
const message = error instanceof Error ? errorToString(error) : JSON.stringify(error);
this.connectionErrorMessage = `${requestDescription} failed: \n${message}`;
this.updateStatus("noConnection");
}
}
if (this.healthCheckMutexAbortController === abortController) {
this.healthCheckMutexAbortController = undefined;
this.updateIsConnecting(false);
} finally {
if (this.healthCheckMutexAbortController === abortController) {
this.healthCheckMutexAbortController = undefined;
this.updateIsConnecting(false);
}
}
}

Expand Down

0 comments on commit 171354e

Please sign in to comment.