angularfire icon indicating copy to clipboard operation
angularfire copied to clipboard

Performance traces are not being reported to firebase anymore

Open misomarcell opened this issue 3 years ago • 8 comments

Version info

**Angular:**14.2.4

**Firebase:**9.10.0

**AngularFire:**7.4.1

How to reproduce these conditions

...
imports: [
    provideFirebaseApp(() => initializeApp(environment.firebase)),
    providePerformance(() => (environment.production ? getPerformance() : undefined)),
]

Note that the environment is in fact production, I've verified it, so the getPerformance() should be evaluated.

Debug output

** Screenshots ** image

Expected behavior

AngularFire Performance reporting performance data to Firebase.

Actual behavior

Not even network requests to firebaselogging.googleapis.com are happening. I've received data only between 11 and 20 of October. The relevant code did not change, so I have no clue why trace reporting stopped after the 20th.

misomarcell avatar Oct 24 '22 23:10 misomarcell

Update

After a couple of days debugging this issue I figured, that performance reports only being sent, if the Performance class is injected at least once, for example in the constructor of the app.component.ts. Weirdly enough I didn't even have to use the the performance instance, it just has to be injected.

I believe it's a bug, since if I only need the traceUntilFirst operators in my app, there's no point injecting this class.

misomarcell avatar Oct 28 '22 13:10 misomarcell

@misomarcell I was having the same problem and injecting the performance class solved my issue, thanks.

Seems like a pretty major issue to have been reported more than 6 months ago and still not being solved.

alethyst avatar May 15 '23 07:05 alethyst

injecting the performance class is no longer a valid workaround for me in version 19. I still don't get performance metrics being reporting, custom or not. I do see in the browser console the following messages:

[2025-05-25T19:48:35.011Z]  Performance: Tries left: 2.
[2025-05-25T19:48:35.011Z]  Performance: Tries left: 1.
[2025-05-25T19:48:35.011Z]  Performance: Tries left: 0.

jakehockey10 avatar May 25 '25 19:05 jakehockey10

I have opened a question on StackOverflow in hopes a resolution reaches more people: https://stackoverflow.com/questions/79639631/angular-fire-19-performance-not-reporting-to-console

jakehockey10 avatar May 26 '25 22:05 jakehockey10

I have found a "solution" to my problem, as mentioned in the stack overflow post linked above.

TLDR;

Somehow events were getting accumulated over time without being posted to firebase and eventually there were close to 200 separate events in the body of the request. Finding the source code for firebase in Chrome DevTools, setting a breakpoint on the call, and limiting the data being sent via navagitor.sendBeacon to just one of these events, seems to have unblocked the stream of events to firebase.

It doesn't seem like the firebase source code handles when too many events accumulate in the request body, and I'm not sure how that even happened in the first place. But this seems to have unblocked me at the moment.

jakehockey10 avatar May 28 '25 01:05 jakehockey10

NVM, issue returned several minutes later. Events accumulated so much that the request body was too large to send to the server. 195 log events, all with the same timestamp:

Image

jakehockey10 avatar May 28 '25 02:05 jakehockey10

https://github.com/firebase/firebase-js-sdk/issues/9067#event-18340390531

This was supposedly resolved on firebase end.

jakehockey10 avatar Jun 27 '25 00:06 jakehockey10

@misomarcell @alethyst The fix on the firebase sdk side has been released: https://github.com/firebase/firebase-js-sdk/issues/9067#issuecomment-3085743499

@jamesdaniels I'm imagining that updating to the latest package mentioned in the link above isn't terribly complicated, but I wasn't sure how I could contribute a pull request to this repository to help get this fix incorporated

jakehockey10 avatar Jul 27 '25 20:07 jakehockey10