Skip to content

Commit 54e0bb8

Browse files
authored
Always send the user agent regardless of the heartbeat value (#6592)
Any non-zero heartbeat value is immediately reset to zero upon retrieval. Thus, should the network request containing the heartbeat value and the user agent string fail, the previous logic would prevent us from sending the user agent string until the next day (when the heartbeat once again returns a non-zero value). Until this is resolved, always send the user agent string, regardless of the heartbeat value. The associated increase in bandwidth usage is minor (~1.2% in _total_ traffic from running the full suite of Firestore integration tests, which represent the worst-case scenario because they recreate the streams much more often than a typical application).
1 parent c93d075 commit 54e0bb8

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Firestore/core/src/remote/firebase_metadata_provider_apple.mm

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,14 @@ FIRHeartbeatInfoCode GetHeartbeat() {
5353
void FirebaseMetadataProviderApple::UpdateMetadata(
5454
grpc::ClientContext& context) {
5555
FIRHeartbeatInfoCode heartbeat = GetHeartbeat();
56-
if (heartbeat == FIRHeartbeatInfoCodeNone) {
57-
return;
56+
// TODO(varconst): don't send any headers if the heartbeat is "none". This
57+
// should only be changed once it's possible to notify the heartbeat that the
58+
// previous attempt to send it has failed.
59+
if (heartbeat != FIRHeartbeatInfoCodeNone) {
60+
context.AddMetadata(kXFirebaseClientLogTypeHeader,
61+
std::to_string(heartbeat));
5862
}
5963

60-
context.AddMetadata(kXFirebaseClientLogTypeHeader, std::to_string(heartbeat));
6164
context.AddMetadata(kXFirebaseClientHeader, GetUserAgent());
6265

6366
std::string gmp_app_id = GetGmpAppId(app_);

0 commit comments

Comments
 (0)