Skip to content

[Heartbeat Service] Guard against empty heartbeat caches. #7749

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/chilly-emus-sit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@firebase/app': patch
---

App - provide a more robust check to cover more cases of empty heartbeat data.
4 changes: 2 additions & 2 deletions packages/app/src/heartbeatService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 '';
Expand Down