How to destroy firebase ref in node

后端 未结 2 502
闹比i
闹比i 2020-12-10 05:52

If I do this in node:

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

outputs:

1
2

And the process ends.

相关标签:
2条回答
  • 2020-12-10 06:31

    [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.

    0 讨论(0)
  • 2020-12-10 06:37

    One workaround I found when using tape was to call test.onFinish(() => process.exit()); at the end. It's not ideal but it seems to get the job done running it both directly and with a test runner.

    Example:

    const test = require('tape');
    
    test('Some test', (t) => {
      // test code
    });
    
    test('Another test', (t) => {
      // test code
    });
    
    test.onFinish(() => process.exit());
    
    0 讨论(0)
提交回复
热议问题