neo4j-driver 4.3.2 → 4.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -129,6 +129,13 @@ var BoltProtocol = /** @class */ (function () {
129
129
  enumerable: false,
130
130
  configurable: true
131
131
  });
132
+ Object.defineProperty(BoltProtocol.prototype, "currentFailure", {
133
+ get: function () {
134
+ return this._responseHandler.currentFailure;
135
+ },
136
+ enumerable: false,
137
+ configurable: true
138
+ });
132
139
  /**
133
140
  * Get the packer.
134
141
  * @return {Packer} the protocol's packer.
@@ -1693,6 +1700,13 @@ var ResponseHandler = /** @class */ (function () {
1693
1700
  this._observer.onError(neo4j_driver_core_1.newError('Unknown Bolt protocol message: ' + msg));
1694
1701
  }
1695
1702
  };
1703
+ Object.defineProperty(ResponseHandler.prototype, "currentFailure", {
1704
+ get: function () {
1705
+ return this._currentFailure;
1706
+ },
1707
+ enumerable: false,
1708
+ configurable: true
1709
+ });
1696
1710
  /*
1697
1711
  * Pop next pending observer form the list of observers and make it current observer.
1698
1712
  * @protected
@@ -4771,7 +4785,8 @@ var RoutingConnectionProvider = /** @class */ (function (_super) {
4771
4785
  };
4772
4786
  RoutingConnectionProvider.prototype._createSessionForRediscovery = function (routerAddress, bookmark) {
4773
4787
  return __awaiter(this, void 0, void 0, function () {
4774
- var connection, connectionProvider, protocolVersion, error_4;
4788
+ var connection, databaseSpecificErrorHandler, connectionProvider, protocolVersion, error_4;
4789
+ var _this = this;
4775
4790
  return __generator(this, function (_a) {
4776
4791
  switch (_a.label) {
4777
4792
  case 0:
@@ -4779,7 +4794,11 @@ var RoutingConnectionProvider = /** @class */ (function (_super) {
4779
4794
  return [4 /*yield*/, this._connectionPool.acquire(routerAddress)];
4780
4795
  case 1:
4781
4796
  connection = _a.sent();
4782
- connectionProvider = new connection_provider_single_1.default(connection);
4797
+ databaseSpecificErrorHandler = connection_1.ConnectionErrorHandler.create({
4798
+ errorCode: SESSION_EXPIRED,
4799
+ handleAuthorizationExpired: function (error, address) { return _this._handleAuthorizationExpired(error, address); }
4800
+ });
4801
+ connectionProvider = new connection_provider_single_1.default(new connection_1.DelegateConnection(connection, databaseSpecificErrorHandler));
4783
4802
  protocolVersion = connection.protocol().version;
4784
4803
  if (protocolVersion < 4.0) {
4785
4804
  return [2 /*return*/, new neo4j_driver_core_1.Session({
@@ -5363,7 +5382,7 @@ var ChannelConnection = /** @class */ (function (_super) {
5363
5382
  */
5364
5383
  ChannelConnection.prototype._handleFatalError = function (error) {
5365
5384
  this._isBroken = true;
5366
- this._error = this.handleAndTransformError(error, this._address);
5385
+ this._error = this.handleAndTransformError(this._protocol.currentFailure || error, this._address);
5367
5386
  if (this._log.isErrorEnabled()) {
5368
5387
  this._log.error("experienced a fatal error " + neo4j_driver_core_1.json.stringify(this._error));
5369
5388
  }
@@ -5406,6 +5425,9 @@ var ChannelConnection = /** @class */ (function (_super) {
5406
5425
  };
5407
5426
  ChannelConnection.prototype._resetOnFailure = function () {
5408
5427
  var _this = this;
5428
+ if (!this.isOpen()) {
5429
+ return;
5430
+ }
5409
5431
  this._protocol.reset({
5410
5432
  onError: function () {
5411
5433
  _this._protocol.resetFailure();
@@ -6835,7 +6857,7 @@ var Unpacker = /** @class */ (function () {
6835
6857
  var prevNode = nodes[0];
6836
6858
  for (var i = 0; i < sequence.length; i += 2) {
6837
6859
  var nextNode = nodes[sequence[i + 1]];
6838
- var relIndex = sequence[i];
6860
+ var relIndex = neo4j_driver_core_1.toNumber(sequence[i]);
6839
6861
  var rel = void 0;
6840
6862
  if (relIndex > 0) {
6841
6863
  rel = rels[relIndex - 1];
@@ -7725,9 +7747,29 @@ var Pool = /** @class */ (function () {
7725
7747
  * @returns {Promise<void>} A promise that is resolved when the resources are purged
7726
7748
  */
7727
7749
  Pool.prototype.close = function () {
7728
- var _this = this;
7729
- this._closed = true;
7730
- return Promise.all(Object.keys(this._pools).map(function (key) { return _this._purgeKey(key); }));
7750
+ return __awaiter(this, void 0, void 0, function () {
7751
+ var _this = this;
7752
+ return __generator(this, function (_a) {
7753
+ switch (_a.label) {
7754
+ case 0:
7755
+ this._closed = true;
7756
+ return [4 /*yield*/, Promise.all(Object.keys(this._pools).map(function (key) { return _this._purgeKey(key); }))];
7757
+ case 1:
7758
+ /**
7759
+ * The lack of Promise consuming was making the driver do not close properly in the scenario
7760
+ * captured at result.test.js:it('should handle missing onCompleted'). The test was timing out
7761
+ * because while wainting for the driver close.
7762
+ *
7763
+ * Consuming the Promise.all or by calling then or by awaiting in the result inside this method solved
7764
+ * the issue somehow.
7765
+ *
7766
+ * PS: the return of this method was already awaited at PooledConnectionProvider.close, but the await bellow
7767
+ * seems to be need also.
7768
+ */
7769
+ return [2 /*return*/, _a.sent()];
7770
+ }
7771
+ });
7772
+ });
7731
7773
  };
7732
7774
  /**
7733
7775
  * Keep the idle resources for the provided addresses and purge the rest.
@@ -9579,7 +9621,7 @@ var Node = /** @class */ (function () {
9579
9621
  * @protected
9580
9622
  * @param {Integer|number} identity - Unique identity
9581
9623
  * @param {Array<string>} labels - Array for all labels
9582
- * @param {Object} properties - Map with node properties
9624
+ * @param {Properties} properties - Map with node properties
9583
9625
  */
9584
9626
  function Node(identity, labels, properties) {
9585
9627
  /**
@@ -9594,7 +9636,7 @@ var Node = /** @class */ (function () {
9594
9636
  this.labels = labels;
9595
9637
  /**
9596
9638
  * Properties of the node.
9597
- * @type {Object}
9639
+ * @type {Properties}
9598
9640
  */
9599
9641
  this.properties = properties;
9600
9642
  }
@@ -9643,7 +9685,7 @@ var Relationship = /** @class */ (function () {
9643
9685
  * @param {Integer|number} start - Identity of start Node
9644
9686
  * @param {Integer|number} end - Identity of end Node
9645
9687
  * @param {string} type - Relationship type
9646
- * @param {Object} properties - Map with relationship properties
9688
+ * @param {Properties} properties - Map with relationship properties
9647
9689
  */
9648
9690
  function Relationship(identity, start, end, type, properties) {
9649
9691
  /**
@@ -9668,7 +9710,7 @@ var Relationship = /** @class */ (function () {
9668
9710
  this.type = type;
9669
9711
  /**
9670
9712
  * Properties of the relationship.
9671
- * @type {Object}
9713
+ * @type {Properties}
9672
9714
  */
9673
9715
  this.properties = properties;
9674
9716
  }
@@ -9713,7 +9755,7 @@ var UnboundRelationship = /** @class */ (function () {
9713
9755
  * @protected
9714
9756
  * @param {Integer|number} identity - Unique identity
9715
9757
  * @param {string} type - Relationship type
9716
- * @param {Object} properties - Map with relationship properties
9758
+ * @param {Properties} properties - Map with relationship properties
9717
9759
  */
9718
9760
  function UnboundRelationship(identity, type, properties) {
9719
9761
  /**
@@ -9728,7 +9770,7 @@ var UnboundRelationship = /** @class */ (function () {
9728
9770
  this.type = type;
9729
9771
  /**
9730
9772
  * Properties of the relationship.
9731
- * @type {Object}
9773
+ * @type {Properties}
9732
9774
  */
9733
9775
  this.properties = properties;
9734
9776
  }
@@ -11246,10 +11288,13 @@ var ConnectionHolder = /** @class */ (function () {
11246
11288
  this._connectionPromise = this._connectionPromise
11247
11289
  .then(function (connection) {
11248
11290
  if (connection) {
11249
- return connection
11250
- .resetAndFlush()
11251
- .catch(ignoreError)
11252
- .then(function () { return connection._release(); });
11291
+ if (connection.isOpen()) {
11292
+ return connection
11293
+ .resetAndFlush()
11294
+ .catch(ignoreError)
11295
+ .then(function () { return connection._release(); });
11296
+ }
11297
+ return connection._release();
11253
11298
  }
11254
11299
  else {
11255
11300
  return Promise.resolve();
@@ -27803,7 +27848,7 @@ exports["default"] = void 0;
27803
27848
  // This is set up this way to keep the version in the code in
27804
27849
  // sync with the npm package version, and to allow the build
27805
27850
  // system to control version names at packaging time.
27806
- var _default = '4.3.2';
27851
+ var _default = '4.3.6';
27807
27852
  exports["default"] = _default;
27808
27853
 
27809
27854
  },{}]},{},[296])(296)