fluxy-bot 0.13.5 → 0.13.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fluxy-bot",
3
- "version": "0.13.5",
3
+ "version": "0.13.6",
4
4
  "releaseNotes": [
5
5
  "1. react router implemented",
6
6
  "2. new workspace design",
@@ -67,10 +67,17 @@ export class WhatsAppChannel implements Channel {
67
67
 
68
68
  if (connection === 'close') {
69
69
  const statusCode = (lastDisconnect?.error as any)?.output?.statusCode;
70
- const isLoggedOut = statusCode === DisconnectReason.loggedOut;
71
70
 
72
- if (isLoggedOut) {
73
- log.warn('[whatsapp] Logged out. Scan QR again to reconnect.');
71
+ // These are the ONLY codes worth retrying — transient network/server issues
72
+ // DisconnectReason enum: connectionClosed=428, connectionLost=408, timedOut=408,
73
+ // restartRequired=515, unavailableService=503
74
+ const TRANSIENT_CODES = new Set([408, 428, 503, 515]);
75
+
76
+ if (!TRANSIENT_CODES.has(statusCode)) {
77
+ // Non-transient: loggedOut(401), badSession(500), forbidden(403),
78
+ // connectionReplaced(440), multideviceMismatch(411), or unknown like 405
79
+ log.warn(`[whatsapp] Connection closed (${statusCode}) — not recoverable by retrying.`);
80
+ log.warn('[whatsapp] WhatsApp inactive. Scan QR code and restart Fluxy to connect.');
74
81
  this.sock = null;
75
82
  return;
76
83
  }
@@ -79,14 +86,13 @@ export class WhatsAppChannel implements Channel {
79
86
 
80
87
  if (this.reconnectAttempts > MAX_RECONNECT_ATTEMPTS) {
81
88
  log.warn(`[whatsapp] Max reconnect attempts (${MAX_RECONNECT_ATTEMPTS}) reached. Giving up.`);
82
- log.warn('[whatsapp] WhatsApp will remain inactive. Restart Fluxy to retry.');
89
+ log.warn('[whatsapp] Restart Fluxy to retry.');
83
90
  this.sock = null;
84
91
  return;
85
92
  }
86
93
 
87
- // Exponential backoff: 5s, 10s, 20s, 40s, 80s
88
94
  const delay = RECONNECT_BASE_DELAY * Math.pow(2, this.reconnectAttempts - 1);
89
- log.warn(`[whatsapp] Connection closed (${statusCode}). Reconnecting in ${delay / 1000}s (attempt ${this.reconnectAttempts}/${MAX_RECONNECT_ATTEMPTS})`);
95
+ log.warn(`[whatsapp] Transient failure (${statusCode}). Reconnecting in ${delay / 1000}s (attempt ${this.reconnectAttempts}/${MAX_RECONNECT_ATTEMPTS})`);
90
96
 
91
97
  this.reconnectTimer = setTimeout(() => {
92
98
  this.reconnectTimer = null;