Skip to content

Commit c348e6b

Browse files
authored
Merge pull request #415 from lutovich/1.7-no-goodbye-when-broken
Do not try to send GOODBYE message when connection is broken
2 parents 0e25da5 + d9b2b9e commit c348e6b

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

src/v1/internal/connection.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,9 @@ export default class Connection {
387387
this._log.debug(`${this} closing`);
388388
}
389389

390-
if (this._protocol) {
391-
// protocol has been initialized
392-
// use it to notify the database about the upcoming close of the connection
390+
if (this._protocol && this.isOpen()) {
391+
// protocol has been initialized and this connection is healthy
392+
// notify the database about the upcoming close of the connection
393393
this._protocol.prepareToClose(NO_OP_OBSERVER);
394394
}
395395

test/internal/connection.test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,27 @@ describe('Connection', () => {
367367
}).catch(done.fail);
368368
});
369369

370+
it('should not prepare broken connection to close', done => {
371+
connection = createConnection('bolt://localhost');
372+
373+
connection.connect('my-connection/9.9.9', basicAuthToken())
374+
.then(() => {
375+
expect(connection._protocol).toBeDefined();
376+
expect(connection._protocol).not.toBeNull();
377+
378+
// make connection seem broken
379+
connection._isBroken = true;
380+
expect(connection.isOpen()).toBeFalsy();
381+
382+
connection._protocol.prepareToClose = () => {
383+
throw new Error('Not supposed to be called');
384+
};
385+
386+
connection.close(() => done());
387+
})
388+
.catch(error => done.fail(error));
389+
});
390+
370391
function packedHandshakeMessage() {
371392
const result = alloc(4);
372393
result.putInt32(0, 1);

test/internal/shared-neo4j.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,13 @@ const additionalConfig = {
108108
'dbms.connector.http.listen_address': 'localhost:7474',
109109

110110
// shorten the default time to wait for the bookmark from 30 to 5 seconds
111-
'dbms.transaction.bookmark_ready_timeout': '5s'
111+
'dbms.transaction.bookmark_ready_timeout': '5s',
112+
113+
// enable GC logging
114+
'dbms.logs.gc.enabled': true,
115+
116+
// enable query logging
117+
'dbms.logs.query.enabled': true
112118
};
113119

114120
const neoCtrlVersionParam = '-e';

0 commit comments

Comments
 (0)