Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

docs(api): note the stop endpoint's multi-node 409 and claim-release intent

Yudhi Armyndharisdd6618d6dad8
diff --git a/docs/06-api-specification.md b/docs/06-api-specification.md
index 251b89e06..a97e47d6e 100644
--- a/docs/06-api-specification.md
+++ b/docs/06-api-specification.md
@@ -577,7 +577,7 @@ No request body.
Returned via `transformSession`; status typically becomes `disconnected`.
-**Errors:** `401` · `403` · `404` not found · `502` `SESSION_STOP_INCOMPLETE` — session stopped locally but the engine teardown did not complete (retryable; the graceful disconnect and the force-destroy escalation both failed, status `disconnected`, no success audit)
+**Errors:** `401` · `403` · `404` not found · `409` another node currently holds this session's live engine (multi-node deployments) · `502` `SESSION_STOP_INCOMPLETE` — session stopped locally but the engine teardown did not complete (retryable; the graceful disconnect and the force-destroy escalation both failed, status `disconnected`, no success audit)
#### POST /api/sessions/:sessionId/logout
diff --git a/src/modules/session/session.service.ts b/src/modules/session/session.service.ts
index c7b53be85..88765e8cd 100644
--- a/src/modules/session/session.service.ts
+++ b/src/modules/session/session.service.ts
@@ -427,6 +427,10 @@ export class SessionService implements OnModuleDestroy, OnModuleInit, OnApplicat
if (this.ownership) await this.assertNotHeldElsewhere(id);
session = await this.engineLifecycle.stop(id);
} catch (error) {
+ // Deliberately no release here, unlike logout()/forceKill(): this catch also carries the
+ // foreign-node 409, where the claim is the peer's and a blanket release would delete it. The
+ // local-502 path keeps the claim, and only claims with a live engine are renewed — it lapses
+ // at lease TTL instead of pinning the session here.
this.discardStopMarkForMissingSession(id, error);
throw error;
}