diff --git a/clients/tabby-agent/src/codeCompletion/index.ts b/clients/tabby-agent/src/codeCompletion/index.ts index 15d1a3de5583..238738076b4d 100644 --- a/clients/tabby-agent/src/codeCompletion/index.ts +++ b/clients/tabby-agent/src/codeCompletion/index.ts @@ -65,7 +65,7 @@ export class CompletionProvider implements Feature { private readonly completionDebounce = new CompletionDebounce(); private readonly completionStats = new CompletionStats(); - private readonly submitStatsTimer: ReturnType; + private submitStatsTimer: ReturnType | undefined = undefined; private lspConnection: Connection | undefined = undefined; private clientCapabilities: ClientCapabilities | undefined = undefined; @@ -80,12 +80,7 @@ export class CompletionProvider implements Feature { private readonly anonymousUsageLogger: AnonymousUsageLogger, private readonly gitContextProvider: GitContextProvider, private readonly recentlyChangedCodeSearch: RecentlyChangedCodeSearch, - ) { - const submitStatsInterval = 1000 * 60 * 60 * 24; // 24h - this.submitStatsTimer = setInterval(async () => { - await this.submitStats(); - }, submitStatsInterval); - } + ) {} initialize(connection: Connection, clientCapabilities: ClientCapabilities): ServerCapabilities { this.lspConnection = connection; @@ -113,6 +108,12 @@ export class CompletionProvider implements Feature { connection.onNotification(TelemetryEventNotification.type, async (param) => { return this.postEvent(param); }); + + const submitStatsInterval = 1000 * 60 * 60 * 24; // 24h + this.submitStatsTimer = setInterval(async () => { + await this.submitStats(); + }, submitStatsInterval); + return serverCapabilities; } diff --git a/clients/tabby-agent/src/http/tabbyApiClient.ts b/clients/tabby-agent/src/http/tabbyApiClient.ts index d412d39f2ff8..ed447ef5671f 100644 --- a/clients/tabby-agent/src/http/tabbyApiClient.ts +++ b/clients/tabby-agent/src/http/tabbyApiClient.ts @@ -54,21 +54,13 @@ export class TabbyApiClient extends EventEmitter { private healthCheckMutexAbortController: AbortController | undefined = undefined; - private readonly reconnectTimer: ReturnType; + private reconnectTimer: ReturnType | undefined = undefined; constructor( private readonly configurations: Configurations, private readonly anonymousUsageLogger: AnonymousUsageLogger, ) { super(); - - const reconnectInterval = 1000 * 30; // 30s - this.reconnectTimer = setInterval(async () => { - if (this.status === "noConnection" || this.status === "unauthorized") { - this.logger.debug("Trying to reconnect..."); - await this.connect(); - } - }, reconnectInterval); } async initialize(clientInfo: ClientInfo | undefined) { @@ -91,6 +83,14 @@ export class TabbyApiClient extends EventEmitter { this.connect(); // no await } }); + + const reconnectInterval = 1000 * 30; // 30s + this.reconnectTimer = setInterval(async () => { + if (this.status === "noConnection" || this.status === "unauthorized") { + this.logger.debug("Trying to reconnect..."); + await this.connect(); + } + }, reconnectInterval); } async shutdown() {