Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
test(session): describe where the reconnect downtime starts
Yudhi Armyndharis133d10cdd444
diff --git a/src/modules/session/session-engine-event-wiring.ts b/src/modules/session/session-engine-event-wiring.tsindex bd6544eb9..875db8794 100644--- a/src/modules/session/session-engine-event-wiring.ts+++ b/src/modules/session/session-engine-event-wiring.ts@@ -138,10 +138,10 @@ export class SessionEngineEventWiring {// presence is the relink signal used below; its value gates onReady's account-binding check.const previouslyLinked = Boolean(previousPhone);let relinkWarned = false;- // When the session was last seen up before the current engine-internal reconnect (epoch ms),- // stamped on attempt 1 or on the first attempt after a READY, and cleared by onReady. An engine- // can carry its attempt counter across a short-lived READY (Baileys does, so a link that drops- // right after opening keeps backing off), and time spent READY is not downtime.+ // When the current engine-internal reconnect streak started (epoch ms): stamped at attempt 1, or+ // at the first reconnect attempt after a READY, and cleared by onReady. An engine can carry its+ // attempt counter across a short-lived READY (Baileys does, so a link that drops right after+ // opening keeps backing off), and time spent READY is not downtime.// Closure state rather than a Map: it is scoped to this engine instance. A service-level// reconnect builds a new engine and a new callback table, so nothing has to be cleaned up.let reconnectingSince = 0;diff --git a/src/modules/session/session.service.spec.ts b/src/modules/session/session.service.spec.tsindex 43c8d0636..134ea654a 100644--- a/src/modules/session/session.service.spec.ts+++ b/src/modules/session/session.service.spec.ts@@ -3844,7 +3844,7 @@ describe('SessionService', () => {// Baileys keeps its attempt counter across a READY that lasted under five minutes, so the next// drop can arrive as attempt 5. The time the session spent READY is not downtime.- it('measures the downtime from the last READY when the attempt count carries across it', async () => {+ it('measures the downtime from the first drop after the last READY when the attempt count carries across it', async () => {const callbacks = await startAndCapture();const sessionErrors = (service as unknown as { sessionErrors: SessionErrorStore }).sessionErrors;const start = Date.now();