如何在节点中销毁firebase ref [英] How to destroy firebase ref in node

查看:103
本文介绍了如何在节点中销毁firebase ref的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  console.log('1'); 
console.log('2');

输出:

  1 
2

结束这个过程。



如果我将其更改为:

  console.log('1'); 
var Firebase = require('firebase');
var ref = new Firebase('https://< base-base> .firebaseio.com /');
console.log('2');

输出:

  1 
2

并且过程继续。 b
$ b

我相信这是因为 ref 会使进程保持活动状态。我知道我可以使用 process.exit ,但我宁愿不这样做。我实际上不希望进程退出,我只是想确保我没有内存泄漏问题,我的firebase ref永远持续。有什么方法可以销毁一个firebase参考一旦我完成了它?

[工程师在Firebase]目前,实例化具有新的Firebase(...)的Firebase客户端将创建一个长期的持久连接,以保持Node.js进程的活跃。



这对于大量的用例来说并不理想,在这里我们有一些工作要做,以确保当没有未完成的Firebase侦听器或未完成的写入服务器时,进程将干净地自动退出,但是这是中/低优先级。我希望在2015年第二季度发布一个修正,希望能在第一季度完成。

If I do this in node:

console.log('1');
console.log('2');

outputs:

1
2

And the process ends.

If I change it to this:

console.log('1');
var Firebase = require('firebase');
var ref = new Firebase('https://<some-base>.firebaseio.com/');
console.log('2');

outputs:

1
2

and the process continues.

I believe that this is because ref is keeping the process alive. I know that I can use process.exit but I would prefer to not do that. I actually don't want the process to exit anyway, I just want to make sure that I don't have a memory leak issue where my firebase ref lasts forever. Is there any way to destroy a firebase reference once I'm done with it?

解决方案

[Engineer at Firebase] Currently, instantiating the Firebase client with new Firebase(...) will create a long-lived persistent connection that keeps the Node.js process alive.

This is admittedly not ideal for a bunch of use cases, and we have some work to do here to ensure that the process exits cleanly and automatically when there are no outstanding Firebase listeners or pending writes to the server, but it's been medium / low priority. I'd expect a "fix" to be released by Q2 '15, hopefully Q1.

这篇关于如何在节点中销毁firebase ref的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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