Firebase-admin-node: Calling `Firebase.initializeApp` more than once causes `default Firebase app already exists` error.

Created on 18 Jun 2019  路  4Comments  路  Source: firebase/firebase-admin-node

ProductName: Mac OS X
ProductVersion: 10.14.4
BuildVersion: 18E226
"firebase-admin": "5.12.1",

When I call Firebase.initializeApp() more than once, I get this error:

Error: The default Firebase app already exists. This means you called initializeApp() more than once without providing an app name as the second argument. In most cases you only need to call initializeApp() once. But if you do want to initialize multiple apps, pass a second argument to initializeApp() to give each app a unique name.

Its really annoying because I want to create isolated servers for each test without having to run a separate instance of Node. Can you please fix this so more than one can run side-by-side?

needs-triage

Most helpful comment

There's nothing to fix. This is how this API is expected to work. If you want to run multiple instances of FirebaseApp, you need to give them different names. See https://firebase.google.com/docs/reference/admin/node/admin.app.App.html#name for some examples.

All 4 comments

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

There's nothing to fix. This is how this API is expected to work. If you want to run multiple instances of FirebaseApp, you need to give them different names. See https://firebase.google.com/docs/reference/admin/node/admin.app.App.html#name for some examples.

Interesting. So I can make up a random string each time?

That's up to you. As far as the SDK is concerned, each instance of FirebaseApp must have a different name.

Was this page helpful?
0 / 5 - 0 ratings