如何在Node.js中关闭Firebase连接 [英] How to close firebase connection in node.js

查看:104
本文介绍了如何在Node.js中关闭Firebase连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我如何使用Firebase的简单示例:

Below is a simple example how I am using firebase:

let firebase = require('firebase');
firebase.initializeApp({
  serviceAccount: './config/firebase.json',
  databaseURL: 'https://thenameofhedatabase.firebaseio.com'
});

let db = firebase.database();
...
...

关键是在执行完所有代码后,db对象将保留node.js会话.我不想呼叫process.exit(0).那么,关闭或处置Firebase db对象的正确方法是什么?

The point is that after all code execution the db object holds the node.js session. I do not want to call process.exit(0). So, what is the right way to close or dispose the db object of the firebase?

推荐答案

这是已在JavaScript SDK 3.4.1版本中修复.

firebase.database().goOffline()现在可以正确释放数据库,以便Node.js进程可以退出.

firebase.database().goOffline() now properly releases the database so the Node.js process can exit.

这篇关于如何在Node.js中关闭Firebase连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆