Skip to content

Commit aa8d80a

Browse files
committed
Merge pull request #44 from oskarhane/1.0-bugs
Bug fixes and config exposure
2 parents a65b4ae + 385b82a commit aa8d80a

File tree

5 files changed

+30
-3
lines changed

5 files changed

+30
-3
lines changed

src/v1/driver.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ class Driver {
5353
this._pool = new Pool(
5454
this._createConnection.bind(this),
5555
this._destroyConnection.bind(this),
56-
this._validateConnection.bind(this)
56+
this._validateConnection.bind(this),
57+
config.connectionPoolSize
5758
);
5859
}
5960

src/v1/internal/connector.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ else {
4242
let
4343
// Signature bytes for each message type
4444
INIT = 0x01, // 0000 0001 // INIT <user_agent>
45-
ACK_FAILURE = 0x0D, // 0000 1101 // ACK_FAILURE
45+
ACK_FAILURE = 0x0E, // 0000 1110 // ACK_FAILURE
4646
RESET = 0x0F, // 0000 1111 // RESET
4747
RUN = 0x10, // 0001 0000 // RUN <statement> <parameters>
4848
DISCARD_ALL = 0x2F, // 0010 1111 // DISCARD *

src/v1/internal/stream-observer.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class StreamObserver {
3939
this._queuedRecords = [];
4040
this._tail = null;
4141
this._error = null;
42+
this._hasFailed = false;
4243
}
4344

4445
/**
@@ -87,6 +88,10 @@ class StreamObserver {
8788
* @param {Object} error - An error object
8889
*/
8990
onError(error) {
91+
if(this._hasFailed) {
92+
return;
93+
}
94+
this._hasFailed = true;
9095
if( this._observer ) {
9196
if( this._observer.onError ) {
9297
this._observer.onError( error );

src/v1/session.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,15 @@ class Session {
8787
* @return
8888
*/
8989
close(cb=(()=>null)) {
90-
this._onClose(cb);
90+
if(this._onClose) {
91+
try {
92+
this._onClose(cb);
93+
} finally {
94+
this._onClose = null;
95+
}
96+
} else {
97+
cb();
98+
}
9199
}
92100
}
93101

test/v1/session.test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
var neo4j = require("../../lib/v1");
2121
var StatementType = require("../../lib/v1/result-summary").statementType;
22+
var Session = require("../../lib/v1/session");
2223

2324
describe('session', function() {
2425

@@ -35,6 +36,18 @@ describe('session', function() {
3536
driver.close();
3637
});
3738

39+
it('close should be idempotent ', function(){
40+
// Given
41+
var counter = 0;
42+
var _session = new Session(null, function(){
43+
counter++;
44+
});
45+
_session.close();
46+
expect(counter).toBe(1);
47+
_session.close();
48+
expect(counter).toBe(1);
49+
})
50+
3851
it('should expose basic run/subscribe ', function(done) {
3952
// Given
4053

0 commit comments

Comments
 (0)