orientechnologies / orientjs

The official fast, lightweight node.js client for OrientDB
http://orientdb.com
Other
326 stars 68 forks source link

Can't get client to close when session creation throws #354

Closed dargolith closed 5 years ago

dargolith commented 5 years ago

Versions

orient-js: 3.0.1
orientdb: 3.0.10

Problem If the OrientDBClient.session call throws (for instance of the db doesn't exist) it seems impossible to cleanup the client state (?), thus preventing expected termination.

Code

const { OrientDBClient } = require('orientjs');

const test = async () => {
  const orientClient = await OrientDBClient.connect({ host: 'localhost', port: 2424 });
  try {
    await orientClient.session({
      name: 'incorrectDbName',  // Non-existing db to make the call throw
      username: 'user',
      password: 'pw',
    });
  } catch (err) {
    console.log('Error:', err);
  } finally {
    await orientClient.close();
  }
};

test();

Expected behavior To terminate correctly.

Actual behavior Locks / hangs forever.

wolf4ood commented 5 years ago

Hi @dargolith

i've just pushed a fix. It will be available in the next OrientJS version 3.0.2

Thanks

dargolith commented 5 years ago

Great! :) Thanks!

wolf4ood commented 5 years ago

Hi @dargolith

OrientJS 3.0.2 is available on NPM with this fix. Thanks