Search code examples
node.jsrequirenodegit

require("nodegit") prevents script from exiting


I'm having trouble using nodegit (v0.9.0). Any .js script that requires the package will hang forever and not exit. Example:

var nodegit = require('nodegit');

console.log("hello world");

Running this on the command line will result in the expected console output, but the script will never exit. I need to use ctrl-C to get control back from the script.

However, if I comment out the require statement:

// var nodegit = require('nodegit');

console.log("hello world");

Things work just fine.

I've encountered this behaviour on both Windows (7) and Linux (CentOS 7.1.1503). Both machines using v4.2.0 of node. I'm guessing that this is not a bug, and that I'm misusing the library somehow, but I don't understand what I could be doing wrong.


Solution

  • It's a bug.

    To work around the problem, you can call process.exit() when you're sure there's no more pending I/O.