How to close firebase connection in node.js

The following is a simple example of how I use firebase:

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

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

The fact is that after executing the code, the object dbcontains a node.js session. I do not want to call process.exit(0). So what is the correct way to close or delete an object dbfor firebase?

+4
source share
1 answer

This is what was fixed in version 3.4.1 of the JavaScript SDK .

firebase.database().goOffline() now correctly frees the database, so the Node.js process may exit.

+8
source

All Articles