Skip to content

Commit

Permalink
fix(agent): fix health chck request canceled error handler.
Browse files Browse the repository at this point in the history
  • Loading branch information
icycodes committed Nov 22, 2024
1 parent 1313bdb commit 415589b
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 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,27 @@ 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.updateStatus("unauthorized");
} else if (isTimeoutError(error)) {
this.logger.error(`Health check request timed out. [${requestId}]`, error);
this.updateStatus("noConnection");
this.connectionErrorMessage = `${requestDescription} timed out.`;
} 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.updateStatus("noConnection");
const message = error instanceof Error ? errorToString(error) : JSON.stringify(error);
this.connectionErrorMessage = `${requestDescription} failed: \n${message}`;
}
} finally {
if (this.healthCheckMutexAbortController === abortController) {
this.healthCheckMutexAbortController = undefined;
this.updateIsConnecting(false);
}
}
if (this.healthCheckMutexAbortController === abortController) {
this.healthCheckMutexAbortController = undefined;
this.updateIsConnecting(false);
}
}

Expand Down

0 comments on commit 415589b

Please sign in to comment.