@celerispay/hazelcast-client 3.12.7-3 → 3.12.7-4

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.
@@ -280,6 +280,13 @@ var ClusterService = /** @class */ (function () {
280
280
  this.client.getConnectionManager().forceCleanupDeadConnections();
281
281
  // Clear partition information
282
282
  this.client.getPartitionService().clearPartitionTable();
283
+ // IMPORTANT: Unblock all down addresses before attempting reconnection.
284
+ // The address was just marked as down by onConnectionClosed/onHeartbeatStopped,
285
+ // but connectToCluster() skips blocked addresses — so without clearing the block
286
+ // it will immediately fail with "Unable to connect to any address".
287
+ // clearAllCredentials() already clears failedConnections inside ConnectionManager.
288
+ this.logger.info('ClusterService', '🔓 SINGLE-NODE RESET: Unblocking all addresses for fresh reconnection...');
289
+ this.downAddresses.clear();
283
290
  // Direct reconnection without waiting for member events
284
291
  this.logger.info('ClusterService', '🔄 SINGLE-NODE RESET: Attempting direct reconnection...');
285
292
  this.connectToCluster()
@@ -806,21 +813,35 @@ var ClusterService = /** @class */ (function () {
806
813
  }
807
814
  // Remove from down addresses to allow connection attempt
808
815
  this.downAddresses.delete(addressStr);
809
- this.logger.debug('ClusterService', "Attempting reconnection to " + addressStr);
810
- // Attempt to establish connection (not as owner, just as regular member connection)
811
- this.client.getConnectionManager().getOrConnect(address, false)
816
+ // Determine whether to connect as owner.
817
+ // If we have no owner connection (e.g. after a single-node restart), we must
818
+ // authenticate as owner so the server assigns fresh UUIDs. Connecting as a
819
+ // non-owner with null UUIDs will always be rejected by the server.
820
+ var needsOwner = !this.ownerConnection || !this.ownerConnection.isHealthy();
821
+ var connectAsOwner = needsOwner;
822
+ this.logger.info('ClusterService', "Attempting reconnection to " + addressStr + " (asOwner=" + connectAsOwner + ", needsOwner=" + needsOwner + ")");
823
+ this.client.getConnectionManager().getOrConnect(address, connectAsOwner)
812
824
  .then(function (connection) {
813
825
  _this.logger.info('ClusterService', "Successfully reconnected to " + addressStr);
814
- // Only evaluate ownership change if we don't have an owner or current owner is unhealthy
815
- if (!_this.ownerConnection || !_this.ownerConnection.isHealthy()) {
816
- _this.logger.info('ClusterService', "Evaluating ownership change for " + addressStr);
817
- _this.evaluateOwnershipChange(address, connection);
826
+ if (connectAsOwner) {
827
+ // We authenticated as owner — make it official and re-register membership listener
828
+ connection.setAuthenticatedAsOwner(true);
829
+ _this.ownerConnection = connection;
830
+ _this.logger.info('ClusterService', "Promoted " + addressStr + " to owner after reconnection");
831
+ // Re-register membership listener so member events resume
832
+ return _this.initMembershipListener().then(function () {
833
+ _this.logger.info('ClusterService', "Membership listener re-registered after reconnection to " + addressStr);
834
+ _this.client.getPartitionService().refresh();
835
+ }).catch(function (err) {
836
+ _this.logger.warn('ClusterService', "Failed to re-register membership listener after reconnection: " + err.message);
837
+ _this.client.getPartitionService().refresh();
838
+ });
818
839
  }
819
840
  else {
841
+ // Non-owner: evaluate if ownership should change (multi-node case)
820
842
  _this.logger.debug('ClusterService', "Keeping " + addressStr + " as member connection, current owner is healthy");
843
+ _this.client.getPartitionService().refresh();
821
844
  }
822
- // Trigger partition service refresh to update routing information
823
- _this.client.getPartitionService().refresh();
824
845
  }).catch(function (error) {
825
846
  _this.logger.warn('ClusterService', "Reconnection attempt to " + addressStr + " failed:", error);
826
847
  // Mark the address as down again, but with a shorter block duration for reconnection attempts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celerispay/hazelcast-client",
3
- "version": "3.12.7-3",
3
+ "version": "3.12.7-4",
4
4
  "description": "Hazelcast - open source In-Memory Data Grid - client for NodeJS with critical connection failover fixes",
5
5
  "main": "./lib/index.js",
6
6
  "scripts": {