@@ -24999,10 +24999,9 @@ var Driver = (function () {
24999
24999
// wrapper around Connection anyway, so it makes little difference.
25000
25000
25001
25001
// Queue up a 'reset', to ensure the next user gets a clean
25002
- // session to work with. No need to flush, this will get sent
25003
- // along with whatever the next thing the user wants to do with
25004
- // this session ends up being, so we save the network round trip.
25002
+ // session to work with.
25005
25003
conn.reset();
25004
+ conn.sync();
25006
25005
25007
25006
// Return connection to the pool
25008
25007
conn._release();
@@ -27577,8 +27576,9 @@ var Chunker = (function (_buf$BaseBuffer) {
27577
27576
}, {
27578
27577
key: 'putBytes',
27579
27578
value: function putBytes(position, data) {
27580
- // TODO: If data is larger than our chunk size or so, we're very likely better off just passing this buffer on rather than doing the copy here
27581
- // TODO: *however* note that we need some way to find out when the data has been written (and thus the buffer can be re-used) if we take that approach
27579
+ // TODO: If data is larger than our chunk size or so, we're very likely better off just passing this buffer on
27580
+ // rather than doing the copy here TODO: *however* note that we need some way to find out when the data has been
27581
+ // written (and thus the buffer can be re-used) if we take that approach
27582
27582
while (data.remaining() > 0) {
27583
27583
// Ensure there is an open chunk, and that it has at least one byte of space left
27584
27584
this._ensure(1);
@@ -27609,10 +27609,10 @@ var Chunker = (function (_buf$BaseBuffer) {
27609
27609
return this;
27610
27610
}
27611
27611
27612
- /**
27612
+ /**
27613
27613
* Bolt messages are encoded in one or more chunks, and the boundary between two messages
27614
27614
* is encoded as a 0-length chunk, `00 00`. This inserts such a message boundary, closing
27615
- * any currently open chunk as needed
27615
+ * any currently open chunk as needed
27616
27616
*/
27617
27617
}, {
27618
27618
key: 'messageBoundary',
@@ -28148,7 +28148,19 @@ var Connection = (function () {
28148
28148
}, {
28149
28149
key: "reset",
28150
28150
value: function reset(observer) {
28151
- this._queueObserver(observer);
28151
+ this._isHandlingFailure = true;
28152
+ var self = this;
28153
+ var wrappedObs = {
28154
+ onNext: observer ? observer.onNext : NO_OP,
28155
+ onError: observer ? observer.onError : NO_OP,
28156
+ onCompleted: function onCompleted() {
28157
+ self._isHandlingFailure = false;
28158
+ if (observer) {
28159
+ observer.onCompleted();
28160
+ }
28161
+ }
28162
+ };
28163
+ this._queueObserver(wrappedObs);
28152
28164
this._packer.packStruct(RESET);
28153
28165
this._chunker.messageBoundary();
28154
28166
}
@@ -29027,10 +29039,10 @@ try {
29027
29039
if (buffer instanceof _buf2['default'].NodeBuffer) {
29028
29040
var start = buffer.position,
29029
29041
end = start + length;
29030
- buffer.position = end;
29042
+ buffer.position = Math.min( end, buffer.length) ;
29031
29043
return buffer._buffer.toString('utf8', start, end);
29032
29044
} else if (buffer instanceof _buf2['default'].CombinedBuffer) {
29033
- var out = streamDecodeCombinedBuffer(buffer._buffers , length, function (partBuffer) {
29045
+ var out = streamDecodeCombinedBuffer(buffer, length, function (partBuffer) {
29034
29046
return decoder.write(partBuffer._buffer);
29035
29047
}, function () {
29036
29048
return decoder.end();
@@ -29059,14 +29071,14 @@ try {
29059
29071
},
29060
29072
"decode": function decode(buffer, length) {
29061
29073
if (buffer instanceof _buf2['default'].HeapBuffer) {
29062
- return decoder.decode(buffer.readView(length));
29074
+ return decoder.decode(buffer.readView(Math.min( length, buffer.length - buffer.position) ));
29063
29075
} else {
29064
29076
// Decoding combined buffer is complicated. For simplicity, for now,
29065
29077
// we simply copy the combined buffer into a regular buffer and decode that.
29066
29078
var tmpBuf = _buf2['default'].alloc(length);
29067
29079
for (var i = 0; i < length; i++) {
29068
29080
tmpBuf.writeUInt8(buffer.readUInt8());
29069
- };
29081
+ }
29070
29082
tmpBuf.reset();
29071
29083
return decoder.decode(tmpBuf.readView(length));
29072
29084
}
@@ -29077,20 +29089,24 @@ try {
29077
29089
29078
29090
var streamDecodeCombinedBuffer = function streamDecodeCombinedBuffer(combinedBuffers, length, decodeFn, endFn) {
29079
29091
var remainingBytesToRead = length;
29092
+ var position = combinedBuffers.position;
29093
+ combinedBuffers._updatePos(Math.min(length, combinedBuffers.length - position));
29080
29094
// Reduce CombinedBuffers to a decoded string
29081
- var out = combinedBuffers.reduce(function (last, partBuffer) {
29095
+ var out = combinedBuffers._buffers. reduce(function (last, partBuffer) {
29082
29096
if (remainingBytesToRead <= 0) {
29083
29097
return last;
29084
- }
29085
- if (partBuffer.length > remainingBytesToRead) {
29086
- // When we don't want the whole buffer
29087
- var lastSlice = partBuffer.readSlice(remainingBytesToRead);
29088
- partBuffer._updatePos(remainingBytesToRead);
29089
- remainingBytesToRead = 0;
29098
+ } else if (position >= partBuffer.length) {
29099
+ position -= partBuffer.length;
29100
+ return '';
29101
+ } else {
29102
+ partBuffer._updatePos(position - partBuffer.position);
29103
+ var bytesToRead = Math.min(partBuffer.length - position, remainingBytesToRead);
29104
+ var lastSlice = partBuffer.readSlice(bytesToRead);
29105
+ partBuffer._updatePos(bytesToRead);
29106
+ remainingBytesToRead = Math.max(remainingBytesToRead - lastSlice.length, 0);
29107
+ position = 0;
29090
29108
return last + decodeFn(lastSlice);
29091
29109
}
29092
- remainingBytesToRead -= partBuffer.length;
29093
- return last + decodeFn(partBuffer);
29094
29110
}, '');
29095
29111
return out + endFn();
29096
29112
};
0 commit comments