Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Having trouble closing db connection #211

Open
StefanoDeVuono opened this issue Jun 17, 2017 · 1 comment
Open

Having trouble closing db connection #211

StefanoDeVuono opened this issue Jun 17, 2017 · 1 comment

Comments

@StefanoDeVuono
Copy link

When I run my test, the database connection stays open at the end, even if I ask to close it:

const wtf = require('wtfnode');

const test = require('tape'),
      db = require('seraph')({
        bolt: true,
        nodeify: true,
        pass: process.env.NEO4JPASSWORD
      });

test('nothing', t => {
  const person = { name: 'Jon', age: 22, likes: 'Beer', test: true };
  db.save(person, function(err, node) {
    let testNode = Object.assign({}, node);
    delete testNode.id;
    t.deepEqual(testNode, person);
    t.end();
  })
})

test.onFinish( () => {
  db.close();
  wtf.dump();
});

wtf shows an open socket, even though I've asked to close my db connection:
127.0.0.1:51255 -> 127.0.0.1:7687

I think this is due to the close method in seraph/bolt calling this.options.session && this.options.session.close();. Since there is no session object on the options key, the close method just returns undefined.

@Raidus
Copy link

Raidus commented Dec 1, 2017

I've did the same test with the official neo4j driver which leaves an open db connection, too.

const wtf = require('wtfnode');
const neo4j = require('neo4j-driver').v1;

// Config
const { NEO_URI, NEO_USER, NEO_PASS } = require('../config/keys');

// Neo4j
const driver = neo4j.driver(NEO_URI, neo4j.auth.basic(NEO_USER, NEO_PASS));
const session = driver.session();

const personName = 'Alice';
const resultPromise = session.run('CREATE (a:Person {name: $name}) RETURN a', {
  name: personName
});

resultPromise
  .then(result => {
    session.close();

    const singleRecord = result.records[0];
    const node = singleRecord.get(0);

    console.log(node.properties.name);

    // on application exit:
    driver.close();
  })
  .then(res => wtf.dump());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants