Skip to content

Commit 27cd5c1

Browse files
committed
Clean-up connections failed on acquire
1 parent 3e1c947 commit 27cd5c1

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/v1/driver.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ class Driver {
144144
// notify Driver.onError callback about connection initialization errors
145145
this.onError(error);
146146
}
147+
// let's destroy this connection
148+
this._destroyConnection(connection);
147149
// propagate the error because connection failed to connect / initialize
148150
throw error;
149151
});

test/v1/driver.test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,20 @@ describe('driver', () => {
7979
startNewTransaction(driver);
8080
}, 10000);
8181

82+
it('should destroy failed connections', done => {
83+
// Given
84+
driver = neo4j.driver('bolt://local-host', sharedNeo4j.authToken);
85+
86+
const session = driver.session();
87+
88+
session.run('RETURN 1').catch(err => {
89+
expect(driver._openConnections).toEqual({});
90+
91+
done();
92+
});
93+
}, 10000);
94+
95+
8296
it('should fail with correct error message when connecting to port 80', done => {
8397
if (testUtils.isClient()) {
8498
// good error message is not available in browser

0 commit comments

Comments
 (0)