@celerispay/hazelcast-client 3.12.5-7 → 3.12.5-8
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.
package/lib/PartitionService.js
CHANGED
|
@@ -69,11 +69,13 @@ var PartitionService = /** @class */ (function () {
|
|
|
69
69
|
var ownerConnection = this.client.getClusterService().getOwnerConnection();
|
|
70
70
|
if (ownerConnection == null) {
|
|
71
71
|
this.logger.warn('PartitionService', 'Cannot refresh partitions, no owner connection available');
|
|
72
|
-
|
|
72
|
+
// Return a rejected promise instead of resolved to indicate failure
|
|
73
|
+
return Promise.reject(new Error('No owner connection available for partition refresh'));
|
|
73
74
|
}
|
|
74
75
|
this.refreshInProgress = true;
|
|
75
76
|
var clientMessage = GetPartitionsCodec.encodeRequest();
|
|
76
|
-
|
|
77
|
+
// Add timeout to prevent hanging
|
|
78
|
+
var refreshPromise = this.client.getInvocationService()
|
|
77
79
|
.invokeOnConnection(ownerConnection, clientMessage)
|
|
78
80
|
.then(function (response) {
|
|
79
81
|
var receivedPartitionMap = GetPartitionsCodec.decodeResponse(response);
|
|
@@ -93,9 +95,17 @@ var PartitionService = /** @class */ (function () {
|
|
|
93
95
|
_this.clearPartitionTable();
|
|
94
96
|
}
|
|
95
97
|
}
|
|
98
|
+
throw e; // Re-throw the error to propagate it
|
|
96
99
|
}).finally(function () {
|
|
97
100
|
_this.refreshInProgress = false;
|
|
98
101
|
});
|
|
102
|
+
// Add timeout to prevent hanging
|
|
103
|
+
var timeoutPromise = new Promise(function (_, reject) {
|
|
104
|
+
setTimeout(function () {
|
|
105
|
+
reject(new Error('Partition refresh timed out'));
|
|
106
|
+
}, 10000); // 10 second timeout
|
|
107
|
+
});
|
|
108
|
+
return Promise.race([refreshPromise, timeoutPromise]);
|
|
99
109
|
};
|
|
100
110
|
/**
|
|
101
111
|
* Returns the {@link Address} of the node which owns given partition id.
|
|
@@ -289,6 +289,10 @@ var InvocationService = /** @class */ (function () {
|
|
|
289
289
|
throw new Error("Still no partition owner for partition " + partitionId + " after refresh");
|
|
290
290
|
}
|
|
291
291
|
return _this.invokeOnAddress(invocation, newOwnerAddress);
|
|
292
|
+
}).catch(function (error) {
|
|
293
|
+
_this.logger.error('InvocationService', "Failed to refresh partition table for partition " + partitionId + ":", error);
|
|
294
|
+
// If partition refresh fails, reject the invocation instead of hanging
|
|
295
|
+
throw new Error("Cannot find partition owner for partition " + partitionId + ": " + error.message);
|
|
292
296
|
});
|
|
293
297
|
}
|
|
294
298
|
return this.client.getConnectionManager().getOrConnect(ownerAddress).then(function (connection) {
|
|
@@ -301,6 +305,10 @@ var InvocationService = /** @class */ (function () {
|
|
|
301
305
|
return _this.client.getPartitionService().refresh().then(function () {
|
|
302
306
|
// Retry the invocation with updated partition information
|
|
303
307
|
return _this.doInvoke(invocation);
|
|
308
|
+
}).catch(function (refreshError) {
|
|
309
|
+
_this.logger.error('InvocationService', "Failed to refresh partition table after partition owner failure:", refreshError);
|
|
310
|
+
// If refresh fails, reject the invocation instead of hanging
|
|
311
|
+
throw new Error("Partition owner " + ownerAddress.toString() + " unavailable and partition refresh failed: " + refreshError.message);
|
|
304
312
|
});
|
|
305
313
|
}
|
|
306
314
|
throw new HazelcastError_1.IOError(ownerAddress.toString() + '(partition owner) is not available.', e);
|
|
@@ -91,9 +91,6 @@ var ProxyManager = /** @class */ (function () {
|
|
|
91
91
|
if (createAtServer) {
|
|
92
92
|
this.createProxy(newProxy).then(function () {
|
|
93
93
|
deferred.resolve(newProxy);
|
|
94
|
-
}).catch(function (error) {
|
|
95
|
-
_this.logger.error('ProxyManager', 'Failed to create proxy for ' + name + ': ' + error);
|
|
96
|
-
deferred.reject(error);
|
|
97
94
|
});
|
|
98
95
|
}
|
|
99
96
|
this.proxies[fullName] = deferred.promise;
|
package/package.json
CHANGED