Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

docs(engine): describe the reconnect reset as a gap between drops

Yudhi Armyndharis4f566ef74b91
diff --git a/src/engine/adapters/baileys-lifecycle.ts b/src/engine/adapters/baileys-lifecycle.ts
index 48ecc7197..762cd3413 100644
--- a/src/engine/adapters/baileys-lifecycle.ts
+++ b/src/engine/adapters/baileys-lifecycle.ts
@@ -177,8 +177,8 @@ export interface BaileysLifecycleHost {
}
export class BaileysLifecycle {
- /** A close more than this long after the previous close means the connection had been healthy in
- * between: the backoff counter restarts from scratch instead of inheriting an old incident's attempts. */
+ /** A close more than this long after the previous close restarts the backoff counter from scratch
+ * instead of inheriting an old incident's attempts. The backoff wait counts toward the gap. */
private static readonly RECONNECT_STABILITY_RESET_MS = 5 * 60_000;
/** How long a first link's history sync must stay silent before the address-book pull runs. */
private static readonly ADDRESSBOOK_QUIET_MS = 20_000;
@@ -699,10 +699,10 @@ export class BaileysLifecycle {
return;
}
- // Stability reset: a close more than 5 minutes after the previous one means the connection had
- // been healthy in between, so the backoff starts fresh instead of inheriting the old counter. A
- // drop sooner than that keeps climbing it, so a link that fails right after each handshake backs
- // off instead of redialing every second or two.
+ // Stability reset: a close more than 5 minutes after the previous one starts the backoff fresh
+ // instead of inheriting the old counter. The gap runs close to close, so the backoff wait counts
+ // toward it. A drop sooner than that keeps climbing it, so a link that fails right after each
+ // handshake backs off instead of redialing every second or two.
// A QR window that ran out resets it too: WhatsApp answered, and a QR left unscanned for hours
// must not add up to a reconnect loop.
const now = Date.now();
diff --git a/src/engine/interfaces/whatsapp-engine.interface.ts b/src/engine/interfaces/whatsapp-engine.interface.ts
index 38307cc2f..128549f55 100644
--- a/src/engine/interfaces/whatsapp-engine.interface.ts
+++ b/src/engine/interfaces/whatsapp-engine.interface.ts
@@ -824,8 +824,8 @@ export interface EngineEventCallbacks {
*
* `attempt` is the 1-based number of the attempt being scheduled. An engine may carry it across a
* short-lived connection, so a link that drops right after opening keeps climbing the backoff; it
- * resets on a scan, when a QR window runs out, or once the connection has stayed healthy for the
- * engine's stability window. An episode can therefore start at attempt > 1 after a brief READY, so a
+ * resets on a scan, when a QR window runs out, or once no drop has occurred for the engine's
+ * stability window. An episode can therefore start at attempt > 1 after a brief READY, so a
* consumer should treat the first attempt after a READY, not only attempt 1, as a new episode.
* The close that ends an unscanned QR window is not a reconnect and is never reported; any other
* close while a QR waits is.