node.js: program either exits unexpectedly or just hangs
问题 I wrote a module in node.js that performs some network operation. I wrote a small script that uses this module (the variable check below). It looks like this: check(obj, function (err, results) { // ... console.log("Check completed"); }); Now here is the interesting thing. When this code executes as part of a mocha test, the test exits as expected. I see the log statement printed and the process exits. When the code is executed as a standalone node script, the log statement gets printed, but