From b952bcf7c0d164c6b05b38669d8566785c3189c4 Mon Sep 17 00:00:00 2001 From: Max Kayander <34479008+mkayander@users.noreply.github.com> Date: Thu, 11 Jan 2024 03:29:56 +0300 Subject: [PATCH] Fix error when `_shutdownStatsbeat` gets called while being undefined (#1259) --- Library/Sender.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Sender.ts b/Library/Sender.ts index 4649c7406..00494e1da 100644 --- a/Library/Sender.ts +++ b/Library/Sender.ts @@ -34,7 +34,7 @@ class Sender { private _config: Config; private _isStatsbeatSender: boolean; - private _shutdownStatsbeat: () => void; + private _shutdownStatsbeat?: () => void; private _failedToIngestCounter: number; private _statsbeatHasReachedIngestionAtLeastOnce: boolean; private _statsbeat: Statsbeat; @@ -200,7 +200,7 @@ class Sender { this._numConsecutiveFailures = 0; if (responseString.includes(INVALID_IKEY) && res.statusCode === 400) { Logging.warn("Instrumentation key was invalid, please check the iKey"); - this._shutdownStatsbeat(); + this._shutdownStatsbeat?.(); } // Handling of Statsbeat instance sending data, should turn it off if is not able to reach ingestion endpoint if (this._isStatsbeatSender && !this._statsbeatHasReachedIngestionAtLeastOnce) {