From 6be3e09e5e82d1fbe23984af919c072fc501690b Mon Sep 17 00:00:00 2001 From: Blake Niemyjski Date: Wed, 22 Feb 2023 19:00:26 -0600 Subject: [PATCH] Fixes #46: Queue timer fires even when api key isn't configured This will also prevent plugin startup and all timers from running. --- packages/core/src/ExceptionlessClient.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/core/src/ExceptionlessClient.ts b/packages/core/src/ExceptionlessClient.ts index a60ed2c1..350ce1bf 100644 --- a/packages/core/src/ExceptionlessClient.ts +++ b/packages/core/src/ExceptionlessClient.ts @@ -32,6 +32,11 @@ export class ExceptionlessClient { await SettingsManager.applySavedServerSettings(this.config); } + if (!this.config.isValid) { + this.config.services.log.warn("Exceptionless is not configured and will not process events."); + return; + } + this.updateSettingsTimer(!!configurationOrApiKey); await EventPluginManager.startup(new PluginContext(this)); @@ -63,9 +68,13 @@ export class ExceptionlessClient { await this.config.services.queue.process(); } - private updateSettingsTimer(startingUp = false) { + private updateSettingsTimer(startingUp: boolean = false) { this.suspendSettingsTimer(); + if (!this.config.isValid) { + return; + } + const interval = this.config.updateSettingsWhenIdleInterval; if (interval > 0) { let initialDelay: number = interval; @@ -73,9 +82,7 @@ export class ExceptionlessClient { initialDelay = this.config.settingsVersion > 0 ? 15000 : 5000; } - this.config.services.log.info( - `Update settings every ${interval}ms (${initialDelay || 0}ms delay)`, - ); + this.config.services.log.info(`Update settings every ${interval}ms (${initialDelay || 0}ms delay)`); // TODO: Look into better async scheduling.. const updateSettings = () => void SettingsManager.updateSettings(this.config);