Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

docs(session): declare the 504 a timed-out start returns in OpenAPI

Yudhi Armyndharis88ce48e2378d
diff --git a/src/modules/session/session.controller.spec.ts b/src/modules/session/session.controller.spec.ts
index 07e24e4c4..bf1b5d128 100644
--- a/src/modules/session/session.controller.spec.ts
+++ b/src/modules/session/session.controller.spec.ts
@@ -580,3 +580,15 @@ describe('SessionController: GET .../groups filters before paginating', () => {
expect(out).toHaveLength(1000);
});
});
+
+// The engine-init deadline and the whatsapp-web.js auth timeout both answer a start with 504, the
+// most common start failure; clients generated from the OpenAPI contract need it declared.
+describe('SessionController.start() OpenAPI responses', () => {
+ it('declares the 504 an engine start timeout returns', () => {
+ const responses = Reflect.getMetadata('swagger/apiResponse', SessionControllerClass.prototype.start) as Record<
+ string,
+ unknown
+ >;
+ expect(Object.keys(responses)).toContain('504');
+ });
+});
diff --git a/src/modules/session/session.controller.ts b/src/modules/session/session.controller.ts
index 816c7e1bc..d0c4d7091 100644
--- a/src/modules/session/session.controller.ts
+++ b/src/modules/session/session.controller.ts
@@ -309,6 +309,13 @@ export class SessionController {
'when a stop or force-kill of this session finished while the start was waiting: the stop ' +
'stands, and a new POST /start clears it and starts the session.',
})
+ @ApiResponse({
+ status: 504,
+ description:
+ 'The engine did not finish starting within its timeout (WhatsApp Web or the network unreachable, ' +
+ 'a stalled browser or resource limit, an unreachable proxyUrl, or the whatsapp-web.js auth ' +
+ 'timeout); the engine is torn down and the start can be retried.',
+ })
async start(@Param('sessionId', ParseUUIDPipe) id: string): Promise<SessionResponseDto> {
const session = await this.sessionService.start(id, { explicit: true });
await this.auditService.logInfo(AuditAction.SESSION_STARTED, {