Skip to content

[6.3.3] can't do initializeApp, crash with Firebase service named 'database' already registered (app/duplicate-service) #2040

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
flelirzin opened this issue Jul 31, 2019 · 3 comments

Comments

@flelirzin
Copy link

A maintenance script used for long time worked well with former versions incl. [email protected]

When upgrading to 6.3.3, it crashes with

(node:19464) UnhandledPromiseRejectionWarning: FirebaseError: Firebase: Firebase service named 'database' already registered (app/duplicate-service).
    at Object.registerService (C:\dev\ng\backend\node_modules\@firebase\app\dist\index.node.cjs.js:359:33)
    at registerDatabase (C:\dev\ng\backend\node_modules\firebase-admin\node_modules\@firebase\database\dist\index.node.cjs.js:15245:39)
    at Object.<anonymous> (C:\dev\ng\backend\node_modules\firebase-admin\node_modules\@firebase\database\dist\index.node.cjs.js:15268:5)
    at Module._compile (module.js:653:30)

Downgrading to 6.3.2, good again.

It crashes very early at the admin.initializeApp(...). Put some console.log to ensure is is called only once.

Imported packages in the script are:

import firebase from "firebase/app";
import "firebase/auth";
import "firebase/database";
import "firebase/firestore";
import "firebase/storage";
import "firebase/functions";
import admin from "firebase-admin";

Win10, node 8

@google-oss-bot
Copy link
Contributor

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.

@Feiyang1
Copy link
Member

Feiyang1 commented Aug 1, 2019

Thanks for reporting this! We recently removed @firebase/app from firebase-admin to solve a version conflict when firebase-admin and firebase are used together.

You are getting this error because you have import "firebase/database" and firebase-admin also import "firebase/database".
You can remove your import "firebase/database" statement and it should solve the problem.

@Feiyang1 Feiyang1 closed this as completed Aug 1, 2019
@flelirzin
Copy link
Author

Thanks a lot, it is the solution. Works again great !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants