Skip to content

Commit 2316fec

Browse files
committed
sync before after reset on session.close
In order to preserve roundtrips we didn't call `sync` after `reset` in `session.close`. However this means that if `session.close` is invoked in order to close a long-running query nothing will happen until you send the next query.
1 parent 9d0db33 commit 2316fec

File tree

5 files changed

+148
-104
lines changed

5 files changed

+148
-104
lines changed

lib/v1/driver.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,9 @@ var Driver = (function () {
158158
// wrapper around Connection anyway, so it makes little difference.
159159

160160
// Queue up a 'reset', to ensure the next user gets a clean
161-
// session to work with. No need to flush, this will get sent
162-
// along with whatever the next thing the user wants to do with
163-
// this session ends up being, so we save the network round trip.
161+
// session to work with.
164162
conn.reset();
163+
conn.sync();
165164

166165
// Return connection to the pool
167166
conn._release();

lib/v1/internal/connector.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,19 @@ var Connection = (function () {
403403
}, {
404404
key: "reset",
405405
value: function reset(observer) {
406-
this._queueObserver(observer);
406+
this._isHandlingFailure = true;
407+
var self = this;
408+
var wrappedObs = {
409+
onNext: observer ? observer.onNext : NO_OP,
410+
onError: observer ? observer.onError : NO_OP,
411+
onCompleted: function onCompleted() {
412+
self._isHandlingFailure = false;
413+
if (observer) {
414+
observer.onCompleted();
415+
}
416+
}
417+
};
418+
this._queueObserver(wrappedObs);
407419
this._packer.packStruct(RESET);
408420
this._chunker.messageBoundary();
409421
}

src/v1/driver.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,9 @@ class Driver {
118118
// wrapper around Connection anyway, so it makes little difference.
119119

120120
// Queue up a 'reset', to ensure the next user gets a clean
121-
// session to work with. No need to flush, this will get sent
122-
// along with whatever the next thing the user wants to do with
123-
// this session ends up being, so we save the network round trip.
121+
// session to work with.
124122
conn.reset();
123+
conn.sync();
125124

126125
// Return connection to the pool
127126
conn._release();

src/v1/internal/connector.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ class Connection {
185185
this._unpacker.structMappers[UNBOUND_RELATIONSHIP] = _mappers.unboundRel;
186186
this._unpacker.structMappers[PATH] = _mappers.path;
187187

188+
189+
188190
let self = this;
189191
// TODO: Using `onmessage` and `onerror` came from the WebSocket API,
190192
// it reads poorly and has several annoying drawbacks. Swap to having
@@ -341,7 +343,19 @@ class Connection {
341343

342344
/** Queue a RESET-message to be sent to the database */
343345
reset( observer ) {
344-
this._queueObserver(observer);
346+
this._isHandlingFailure = true;
347+
let self = this;
348+
let wrappedObs = {
349+
onNext: observer ? observer.onNext : NO_OP,
350+
onError: observer ? observer.onError : NO_OP,
351+
onCompleted: () => {
352+
self._isHandlingFailure = false;
353+
if (observer) {
354+
observer.onCompleted();
355+
}
356+
}
357+
};
358+
this._queueObserver(wrappedObs);
345359
this._packer.packStruct( RESET );
346360
this._chunker.messageBoundary();
347361
}

0 commit comments

Comments
 (0)