Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

node process doesn't exit after firebase once

Tags:

Using node.js with the npm firebase.

var firebase = require('firebase'); var blahFirebase = new firebase('https://myfirebase.firebaseIO.com/blah'); blahFirebase.once('value', function (snapshot) {     // }); 

Why does node not exit when it is done reading the data?

like image 808
Tomas Re Avatar asked Aug 04 '13 19:08

Tomas Re


2 Answers

In the new Firebase API you should use firebase.app.App.delete() to free the resources its holding. For example:

var app = firebase.initializeApp({ ... }); var db = firebase.database();  // Do something  app.delete(); // Release resources 

Do not use process.exit() since it will stop the entire process (which is not what you would usually want).

like image 154
locker47 Avatar answered Nov 12 '22 23:11

locker47


My case is using firebase admin,

const  admin = require('firebase-admin'); 

and I can end node process by

return admin.app().delete(); 
like image 21
William Wu Avatar answered Nov 12 '22 22:11

William Wu