diff --git a/.changeset/chilly-emus-sit.md b/.changeset/chilly-emus-sit.md new file mode 100644 index 00000000000..00b6fb60135 --- /dev/null +++ b/.changeset/chilly-emus-sit.md @@ -0,0 +1,5 @@ +--- +'@firebase/app': patch +--- + +App - provide a more robust check to cover more cases of empty heartbeat data. diff --git a/packages/app/src/heartbeatService.ts b/packages/app/src/heartbeatService.ts index 0c15460ba61..5febd64c550 100644 --- a/packages/app/src/heartbeatService.ts +++ b/packages/app/src/heartbeatService.ts @@ -88,7 +88,7 @@ export class HeartbeatServiceImpl implements HeartbeatService { // service, not the browser user agent. const agent = platformLogger.getPlatformInfoString(); const date = getUTCDateString(); - if (this._heartbeatsCache === null) { + if (this._heartbeatsCache?.heartbeats == null) { this._heartbeatsCache = await this._heartbeatsCachePromise; } // Do not store a heartbeat if one is already stored for this day @@ -128,7 +128,7 @@ export class HeartbeatServiceImpl implements HeartbeatService { } // If it's still null or the array is empty, there is no data to send. if ( - this._heartbeatsCache === null || + this._heartbeatsCache?.heartbeats == null || this._heartbeatsCache.heartbeats.length === 0 ) { return '';