Help us understand the problem. What is going on with this article?

nodejs で firestore を利用した際にプロセス終了できなくなった時の対応

(2019/4/4 追記: そもそも nodejs で実行する環境 (Cloud Functions など)であれば firebase-admin を利用する方が何かと都合がよく、app.delete() せずともプロセス終了可能だった、というか delete メソッドがそもそもない。)

標題の件。

どうにもプロセスが終了しないので、process.exit() してみたが行儀がよくなさそうなのでもう少し調べたら app.delete() で終了できるという情報があった。

node process doesn't exit after firebase once
https://stackoverflow.com/questions/18046639/node-process-doesnt-exit-after-firebase-once

use firebase.delete() instead. firebase.google.com/docs/reference/node/firebase.app.App#delete – pantos27 Jun 13 '17 at 20:58

コード例

自分のケースだと firestore を利用していたので、db.app.delete() することでプロセスを終了することができた。

const db = firebase.firestore()
const usersRef = db.collection('users')

usersRef
  .get()
  .then((snapshot) => {
    // 処理 ...

    // app インスタンスを消す(閉じる)ことによりプロセス終了できるようになる
    db.app.delete()
  })
Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away