Skip to content

Commit

Permalink
Fix IllegalStateException when starting a trace before Firebase init (#…
Browse files Browse the repository at this point in the history
…6371)

Fix IllegalStateException when starting a trace before Firebase
initializes.

This can happen if you manually initialize Firebase. See #4693
  • Loading branch information
mrober authored Oct 11, 2024
1 parent 60a5e4c commit 8869a14
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions firebase-perf/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Unreleased
* [fixed] Fix IllegalStateException when starting a trace before Firebase initializes.
* [changed] Updated protobuf dependency to `3.25.5` to fix
[CVE-2024-7254](https://github.com/advisories/GHSA-735f-pc8j-v9w8).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,13 @@ private RemoteConfigManager() {
@VisibleForTesting
@SuppressWarnings("FirebaseUseExplicitDependencies")
static long getInitialStartupMillis() {
StartupTime startupTime = FirebaseApp.getInstance().get(StartupTime.class);
StartupTime startupTime = null;
try {
startupTime = FirebaseApp.getInstance().get(StartupTime.class);
} catch (IllegalStateException ex) {
// This can happen if you start a trace before Firebase is init
logger.debug("Unable to get StartupTime instance.");
}
if (startupTime != null) {
return startupTime.getEpochMillis();
} else {
Expand Down

0 comments on commit 8869a14

Please sign in to comment.