You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Which of course is totally cool if someone would have also told the 'firebase-admin' team. Because if you add one single line to your import statement:
the application will totally freak out and throw an error saying 'Firebase: Firebase service named \'database\' already registered (app/duplicate-service).'
I haven't really looked into the code but I'm guessing that the import 'firebase/database' is pro-actively registering the database service for the default firebase instance. The firebase-admin probably also has an import of 'firebase/database' somewhere which will cause the database service to try and register twice.
A possible solution would be to remove the code block which tells us that we cannot register a service twice and simply return the existing instance if the service already exists.
Relevant Code:
A workaround seems to be to make the imports dynamic:
constfb=firebase.initializeApp(config,name);if(!(<any>fb).services_['auth'] || !(<any>fb).services_['auth'][fb.name]) require('firebase/auth');
if (!(<any>fb).services_['storage'] || !(<any>fb).services_['storage'][fb.name]) require('firebase/storage');
if (!(<any>fb).services_['database'] || !(<any>fb).services_['database'][fb.name]) require('firebase/database');
The text was updated successfully, but these errors were encountered:
Describe your environment
Describe the problem
You cannot combine firebase 5.x loading mechanism with firebase-admin.
Steps to reproduce:
Starting with firebase 5, the new way of importing firebase and the firebase services is
Which of course is totally cool if someone would have also told the 'firebase-admin' team. Because if you add one single line to your import statement:
the application will totally freak out and throw an error saying
'Firebase: Firebase service named \'database\' already registered (app/duplicate-service).'
I haven't really looked into the code but I'm guessing that the import 'firebase/database' is pro-actively registering the database service for the default firebase instance. The firebase-admin probably also has an import of 'firebase/database' somewhere which will cause the database service to try and register twice.
A possible solution would be to remove the code block which tells us that we cannot register a service twice and simply return the existing instance if the service already exists.
Relevant Code:
A workaround seems to be to make the imports dynamic:
The text was updated successfully, but these errors were encountered: