Skip to content

Commit 1ace19c

Browse files
committed
Extra guards against empty heartbeatsCache objects in hearbeatService.ts
1 parent ff1a6ec commit 1ace19c

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

packages/app/src/heartbeatService.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export class HeartbeatServiceImpl implements HeartbeatService {
8888
// service, not the browser user agent.
8989
const agent = platformLogger.getPlatformInfoString();
9090
const date = getUTCDateString();
91-
if (this._heartbeatsCache === null) {
91+
if (this._heartbeatsCache?.heartbeats == null) {
9292
this._heartbeatsCache = await this._heartbeatsCachePromise;
9393
}
9494
// Do not store a heartbeat if one is already stored for this day
@@ -127,10 +127,8 @@ export class HeartbeatServiceImpl implements HeartbeatService {
127127
await this._heartbeatsCachePromise;
128128
}
129129
// If it's still null or the array is empty, there is no data to send.
130-
if (
131-
this._heartbeatsCache === null ||
132-
this._heartbeatsCache.heartbeats.length === 0
133-
) {
130+
if (this._heartbeatsCache?.heartbeats == null ||
131+
this._heartbeatsCache.heartbeats.length === 0) {
134132
return '';
135133
}
136134
const date = getUTCDateString();

0 commit comments

Comments
 (0)