Skip to content

Commit 1cc3bf4

Browse files
committed
Send INIT eagerly
There is no benefit of queuing the INIT message and it makes error handling trickier.
1 parent fab6d7c commit 1cc3bf4

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/v1/internal/connector.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ class Connection {
323323
this._packer.packStruct( INIT, [this._packable(clientName), this._packable(token)],
324324
(err) => this._handleFatalError(err) );
325325
this._chunker.messageBoundary();
326+
this.sync();
326327
}
327328

328329
/** Queue a RUN-message to be sent to the database */

test/v1/driver.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,19 @@ describe('driver', function() {
4747
// When
4848
driver.session();
4949
});
50+
51+
it('should fail early on wrong credentials', function(done) {
52+
// Given
53+
var driver = neo4j.driver("bolt://localhost", neo4j.auth.basic("neo4j", "who would use such a password"));
54+
55+
// Expect
56+
driver.onError = function (err) {
57+
//the error message is different whether in browser or node
58+
expect(err.fields[0].code).toEqual('Neo.ClientError.Security.Unauthorized');
59+
done();
60+
};
61+
62+
// When
63+
driver.session();
64+
});
5065
});

0 commit comments

Comments
 (0)