orientechnologies / orientjs

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

Error on closing database connection #312

Open mahmed8003 opened 6 years ago

mahmed8003 commented 6 years ago

Following code giving error at closing of db connection.

const OrientDB = require('orientjs');
const config = require('../config');

const startProcess = async function () {
    const db = new OrientDB.ODatabase(config.db);

    const user = await db.class.create('User');
    const userProps = await user.property.create([
        {
            name: 'amount',
            type: 'Double',
            min: 0.0,
            max: 100.0,
            mandatory: true
        },
        {
            name: 'name',
            type: 'String',
            mandatory: true,
        },
    ]);

    const education = await db.class.create('Education');
    const educationProps = await education.property.create([
        {
            name: 'title',
            type: 'String',
            mandatory: true,
        },
    ]);

    // Close the database connection
    await db.close();

}

startProcess();

Error is:

> node ./scripts/create-schema.js

/****/node_modules/orientjs/lib/transport/binary/connection.js:187
      this.socket.removeAllListeners();
                  ^

TypeError: Cannot read property 'removeAllListeners' of null
    at Connection.<anonymous> (/****/node_modules/orientjs/lib/transport/binary/connection.js:187:19)
    at Object.onceWrapper (events.js:273:13)
    at Socket.emit (events.js:187:15)
    at TCP._handle.close [as _onclose] (net.js:596:12)