在 node.js 中,我使用 oriento 模块来访问 OrientDB。原则上一切正常,唯一的事情是程序没有按应有的方式退出。这是示例:
const oriento = require("oriento");
const server = oriento({});
const db = server.use(dbname);
db.select("@rid").from("codelists").limit(1).scalar().then(function (result) {
console.dir(result);
}).finally(function () {
db.close();
server.close();
console.info("finished");
});
程序执行 select,然后是“then”,最后是“finally”子句。一切都好。但它不会退出。事件循环上似乎有一些东西。但是什么?我怎样才能摆脱它?问题实际上比“按 Ctrl-C”或在一切完成后使用 process.exit() 更糟糕,因为代码应该在单元测试中运行,而我无法调用 exit。有什么建议么?