@aichatwar/shared 1.0.105 → 1.0.107

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.
@@ -14,7 +14,7 @@ class Listener {
14
14
  constructor(consumer) {
15
15
  this.ackDeadline = 5 * 1000; // 5 seconds
16
16
  this.retryCount = 0;
17
- this.maxInitialRetries = 5; // Show detailed retry logs for first 5 attempts
17
+ this.maxInitialRetries = 3; // Show detailed retry logs for first 3 attempts
18
18
  this.maxRetryDelay = 60000; // Cap delay at 60 seconds
19
19
  this.isListening = false; // Track if listener is active
20
20
  this.crashHandlerSetup = false; // Track if crash handler has been set up
@@ -66,9 +66,15 @@ class Listener {
66
66
  topic: this.topic,
67
67
  fromBeginning: false,
68
68
  });
69
+ // Log success message, especially if there were previous retries
70
+ if (this.retryCount > 0) {
71
+ console.log(`✅ [${this.topic}] Successfully connected after ${this.retryCount} retry attempts. Listening with groupId: ${this.groupId}`);
72
+ }
73
+ else {
74
+ console.log(`✅ [${this.topic}] Successfully connected. Listening to topic with groupId: ${this.groupId}`);
75
+ }
69
76
  // Reset retry count on successful connection
70
77
  this.retryCount = 0;
71
- console.log(`[${this.topic}] Listening to topic with groupId: ${this.groupId}`);
72
78
  yield this.consumer.run({
73
79
  eachMessage: (payload) => __awaiter(this, void 0, void 0, function* () {
74
80
  if (!payload.message.value)
@@ -108,11 +114,11 @@ class Listener {
108
114
  const delay = Math.min(5000 * Math.pow(2, Math.min(this.retryCount - 1, 6)), this.maxRetryDelay);
109
115
  // Show detailed logs for first few attempts, then less frequently
110
116
  if (this.retryCount <= this.maxInitialRetries) {
111
- console.warn(`[${this.topic}] Topic partition error (attempt ${this.retryCount}/${this.maxInitialRetries}): ${error.message}. Retrying in ${delay}ms...`);
117
+ console.warn(`[${this.topic}] Topic partition error (attempt ${this.retryCount}/${this.maxInitialRetries}, will continue indefinitely): ${error.message}. Retrying in ${delay}ms...`);
112
118
  }
113
119
  else if (this.retryCount % 10 === 0) {
114
120
  // Log every 10th retry after initial attempts to avoid log spam
115
- console.warn(`[${this.topic}] Still retrying subscription (attempt ${this.retryCount}). Topic may not exist yet or has no data. Retrying in ${delay}ms...`);
121
+ console.warn(`[${this.topic}] Still retrying subscription (attempt ${this.retryCount}, retrying indefinitely). Topic may not exist yet or has no data. Retrying in ${delay}ms...`);
116
122
  }
117
123
  // Retry indefinitely with exponential backoff
118
124
  // This allows the listener to connect once the topic becomes available
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aichatwar/shared",
3
- "version": "1.0.105",
3
+ "version": "1.0.107",
4
4
  "main": "./build/index.js",
5
5
  "typs": "./build/index.d.ts",
6
6
  "files": [