From 01c9c2ca564e8bdaefe2f20e890dabe2e00cd702 Mon Sep 17 00:00:00 2001 From: devlikepro Date: Thu, 4 Dec 2025 20:53:24 -0800 Subject: [PATCH] [core] session FAILED if apps not started --- src/core/abc/session.abc.ts | 2 +- src/core/manager.core.ts | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/core/abc/session.abc.ts b/src/core/abc/session.abc.ts index fc7ceac2..781c83c9 100644 --- a/src/core/abc/session.abc.ts +++ b/src/core/abc/session.abc.ts @@ -321,7 +321,7 @@ export abstract class WhatsappSession { return this.events2.get(event); } - protected set status(value: WAHASessionStatus) { + public set status(value: WAHASessionStatus) { if (this.unpairing && value !== WAHASessionStatus.STOPPED) { // In case of unpairing // wait for STOPPED event, ignore the rest diff --git a/src/core/manager.core.ts b/src/core/manager.core.ts index d151195d..75785c0e 100644 --- a/src/core/manager.core.ts +++ b/src/core/manager.core.ts @@ -218,11 +218,20 @@ export class SessionManagerCore extends SessionManager implements OnModuleInit { webhook.configure(session, webhooks); // Apps - await this.appsService.beforeSessionStart(session, this.store); + try { + await this.appsService.beforeSessionStart(session, this.store); + } catch (e) { + logger.error(`Apps Error: ${e}`); + session.status = WAHASessionStatus.FAILED; + } // start session - await session.start(); - logger.info('Session has been started.'); + if (session.status !== WAHASessionStatus.FAILED) { + await session.start(); + logger.info('Session has been started.'); + // Apps + await this.appsService.afterSessionStart(session, this.store); + } // Apps await this.appsService.afterSessionStart(session, this.store);