简体   繁体   English

选择后没有退出带有oriento的节点程序

[英]Node program with oriento does not exit after select

From within node.js I use the oriento module to access a OrientDB. 在node.js中,我使用oriento模块访问OrientDB。 In principle everything works fine, the only thing is the program dos not exit as it should. 原则上,一切正常,唯一的问题是程序不会按预期退出。 Here is the example: 这是示例:

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");
});

The programm executes the select, then the "then" and finally the "finally" clauses. 程序执行select,然后执行“ then”子句,最后执行“ finally”子句。 All fine. 一切都很好。 But it does not exit. 但是它不会退出。 There seems to be something hanging on the event loop. 事件循环似乎挂着一些东西。 But what? 但是呢 And how can I get rid of it? 我该如何摆脱呢? The problem actually is worse then just "press Ctrl-C" or have a process.exit() when everything is done, because the code is supposed to run within a unit test, where I cannot call exit. 问题实际上更加严重,然后在完成所有操作后仅“按Ctrl-C”或具有process.exit(),因为代码应该在单元测试中运行,而我无法调用exit。 Any suggestions? 有什么建议么?

The problem is solved in the current master version of oriento. 在oriento的当前主版本中解决了该问题。 https://github.com/codemix/oriento/issues/170 https://github.com/codemix/oriento/issues/170

You can use process._getActiveRequests() and process._getActiveHandles() to see what's holding the app open. 您可以使用process._getActiveRequests()process._getActiveHandles()来查看使应用程序处于打开状态的内容。 They are undocumented but commonly used in this scenario. 它们没有记录,但在这种情况下通常使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM