magmastream 2.10.3-alpha.2 → 2.10.3-alpha.3
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/dist/structures/Node.js +6 -4
- package/package.json +1 -1
package/dist/structures/Node.js
CHANGED
|
@@ -29,7 +29,7 @@ class Node {
|
|
|
29
29
|
/** Whether the node is a NodeLink. */
|
|
30
30
|
isNodeLink = false;
|
|
31
31
|
reconnectTimeout;
|
|
32
|
-
reconnectAttempts =
|
|
32
|
+
reconnectAttempts = 0;
|
|
33
33
|
redisPrefix;
|
|
34
34
|
/** Session ID sent in the reconnect header for resumption — cleared once the ready op is received. */
|
|
35
35
|
pendingResumeSessionId = null;
|
|
@@ -313,7 +313,7 @@ class Node {
|
|
|
313
313
|
// Always clear reconnect state regardless of connection status
|
|
314
314
|
clearTimeout(this.reconnectTimeout);
|
|
315
315
|
this.reconnectTimeout = undefined;
|
|
316
|
-
this.reconnectAttempts =
|
|
316
|
+
this.reconnectAttempts = 0;
|
|
317
317
|
// Only close the socket if it is actually open
|
|
318
318
|
if (this.connected) {
|
|
319
319
|
this.socket.close(1000, "destroy");
|
|
@@ -349,7 +349,8 @@ class Node {
|
|
|
349
349
|
};
|
|
350
350
|
this.manager.emit(Enums_1.ManagerEventTypes.Debug, `[NODE] Reconnecting node: ${Utils_1.JSONUtils.safe(debugInfo, 2)}`);
|
|
351
351
|
this.reconnectTimeout = setTimeout(async () => {
|
|
352
|
-
|
|
352
|
+
this.reconnectAttempts++;
|
|
353
|
+
if (this.reconnectAttempts > this.options.maxRetryAttempts) {
|
|
353
354
|
const error = new MagmastreamError_1.MagmaStreamError({
|
|
354
355
|
code: Enums_1.MagmaStreamErrorCode.NODE_RECONNECT_FAILED,
|
|
355
356
|
message: `Unable to reconnect after ${this.options.maxRetryAttempts} attempts.`,
|
|
@@ -362,7 +363,6 @@ class Node {
|
|
|
362
363
|
this.socket = null;
|
|
363
364
|
this.manager.emit(Enums_1.ManagerEventTypes.NodeReconnect, this);
|
|
364
365
|
await this.connect();
|
|
365
|
-
this.reconnectAttempts++;
|
|
366
366
|
}, this.options.retryDelayMs);
|
|
367
367
|
}
|
|
368
368
|
/**
|
|
@@ -384,6 +384,8 @@ class Node {
|
|
|
384
384
|
open() {
|
|
385
385
|
if (this.reconnectTimeout)
|
|
386
386
|
clearTimeout(this.reconnectTimeout);
|
|
387
|
+
this.reconnectTimeout = undefined;
|
|
388
|
+
this.reconnectAttempts = 0;
|
|
387
389
|
const debugInfo = {
|
|
388
390
|
identifier: this.options.identifier,
|
|
389
391
|
connected: this.connected,
|