Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot destroy Firebase connections making hot Lambda fail due to 'Firebase App name '[DEFAULT]' already exists'

Been trying every approach I can think of for hours.

Basically I'm running an AWS Lambda function which does some work to my Firebase app in both a client and server role.

Being on Lambda, I need to be able to reverse the firebase.initializeApp(config) and firebase.initializeApp(config, 'server'). I've tried firebase.app('server').delete() but that doesn't seem to work.

Thanks in advance for any help.

To clarify, I can't just use the existing connection because the config may change.

like image 871
Bryce York Avatar asked Nov 29 '25 02:11

Bryce York


2 Answers

Calls to initializeApp take an optional app name. If the app name is not specified, the name [DEFAULT] is used.

To uninitialize an app, you need to call delete on the app instance. The app instance is returned by the initializeApp call or can be obtained using the app function.

That is, you can initialize and uninitialize an app like this:

app = firebase.initializeApp(configuration);
app.delete();

Or like this:

firebase.initializeApp(configuration);
firebase.app('[DEFAULT]').delete();

Note that the delete function returns a promise that resolves when the app deletion is complete.

like image 58
cartant Avatar answered Dec 01 '25 20:12

cartant


initializeApp returns the initialized app. You can do :

const app = firebase.initializeApp(config);
//...
await app.delete();
like image 36
Dorian Marchal Avatar answered Dec 01 '25 20:12

Dorian Marchal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!