Node program with oriento does not exit after select

224 views Asked by At

From within node.js I use the oriento module to access a 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. 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. Any suggestions?

2

There are 2 answers

0
Gregor On BEST ANSWER

The problem is solved in the current master version of oriento. https://github.com/codemix/oriento/issues/170

1
Timothy Strimple On

You can use process._getActiveRequests() and process._getActiveHandles() to see what's holding the app open. They are undocumented but commonly used in this scenario.