Frank Deaton
Frank Deaton

Reputation: 11

Updating from firebase 6.0 to 6.1 is breaking my cloud functions app initialization

After being forced to update my firebase code to 6.1, I have come across the issue of this code snippet not properly checking to see if the default app has been initialized.

if(!admin.apps.length)
{   
   admin.initializeApp();
}

This was working fine before and now it never initializes the app.

Upvotes: 0

Views: 16

Answers (1)

Frank Deaton
Frank Deaton

Reputation: 11

I changed my code to

if(!admin.apps.length || admin.apps.length === 1)
{   
   admin.initializeApp();
}

it turns out that admin.apps length is 1 when there isn't a default app initialized and it now works correctly as it did before. Hopefully this helps out someone else with the same problem.

Upvotes: 1

Related Questions