无法破坏Firebase连接,导致热Lambda失败,原因是"Firebase应用程序名称'[DEFAULT]'已经存在" [英] 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.
基本上,我正在运行一个AWS Lambda函数,该函数以客户端和服务器角色的身份对我的Firebase应用程序进行了一些工作.
Basically I'm running an AWS Lambda function which does some work to my Firebase app in both a client and server role.
在Lambda上,我需要能够反转firebase.initializeApp(config)
和firebase.initializeApp(config, 'server')
.我已经尝试过firebase.app('server').delete()
,但这似乎不起作用.
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.
在此先感谢您的帮助.
为澄清起见,我不能仅使用现有连接,因为配置可能会更改.
To clarify, I can't just use the existing connection because the config may change.
推荐答案
对initializeApp
的调用采用可选的应用程序名称.如果未指定应用程序名称,则使用名称[DEFAULT]
.
Calls to initializeApp
take an optional app name. If the app name is not specified, the name [DEFAULT]
is used.
要取消初始化应用程序,您需要在应用程序实例上调用delete
.该应用程序实例是通过initializeApp
调用返回的,或者可以使用app
函数获得.
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();
或者像这样:
firebase.initializeApp(configuration);
firebase.app('[DEFAULT]').delete();
请注意,delete
函数返回的诺言将在应用程序删除完成时解决.
Note that the delete
function returns a promise that resolves when the app deletion is complete.
这篇关于无法破坏Firebase连接,导致热Lambda失败,原因是"Firebase应用程序名称'[DEFAULT]'已经存在"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!