为什么我的async.waterfall JavaScript的顺序代码没有结束?

当我运行下面的代码,顺序连接到MongoDB,然后closures,在javascript中使用async.waterfall程序不会按预期结束。 相反,它似乎只是在“数据库closures”行之后等待。

$ node test-async2.js hit connectMongo Connected correctly to server, DB: notes hit closeMongo DB closed [program just waits here, doesn't end] 

我曾期待该计划结束。 我犯了什么错误?

 const async = require('async'), MongoClient = require('mongodb').MongoClient, url = 'mongodb://localhost:27017/notes'; function connectMongo(next) { console.log('hit connectMongo'); MongoClient.connect(url, function(err, db) { console.log("Connected to server, DB: " + db.databaseName); next(null, db); }); } function closeMongo(db, next) { console.log('hit closeMongo'); db.close; next(null, "DB closed"); } // perform connect then close sequentially async.waterfall([ connectMongo, closeMongo, ], function (err, result) { if (err) throw err; console.log(result); }); 

       

网上收集的解决方案 "为什么我的async.waterfall JavaScript的顺序代码没有结束?"