Skip to content

A self-hosted UPI & COD payment gateway with zero per-transaction platform fees, universal JavaScript checkout integration, dynamic QR payments, WhatsApp OTP authentication, and automated payment verification.

JavaScript

fix(gmail-observer): honor stop during pending boot checks

generaltony0071707fa281d1c
diff --git a/apps/gmail-observer/src/gmail-poller.js b/apps/gmail-observer/src/gmail-poller.js
index e73407a..60b97ea 100644
--- a/apps/gmail-observer/src/gmail-poller.js
+++ b/apps/gmail-observer/src/gmail-poller.js
@@ -78,6 +78,7 @@ export class GmailPoller {
this.degradedReason = null;
this.lastBootCheckAt = null;
this.bootRetryTimer = null;
+ this.bootVersion = 0;
this.backoffDelayMs = 5000;
}
@@ -118,6 +119,7 @@ export class GmailPoller {
* @returns {Promise<{ success: boolean, state: string, reason?: string }>}
*/
async startBootLifecycle() {
+ const bootVersion = ++this.bootVersion;
this.lastBootCheckAt = new Date().toISOString();
// 1. Validate receiving account ID
@@ -131,6 +133,7 @@ export class GmailPoller {
if (!this.credentials?.refreshToken || !this.credentials?.clientId || !this.credentials?.clientSecret) {
await this.fetchCredentialsFromPaymentApi();
}
+ if (bootVersion !== this.bootVersion) return { success: false, state: this.lifecycleState };
const { clientId, clientSecret, refreshToken } = this.credentials || {};
if (!clientId || !clientSecret || !refreshToken) {
@@ -141,6 +144,7 @@ export class GmailPoller {
// 3. Test token acquisition
const token = await this.getAccessToken();
+ if (bootVersion !== this.bootVersion) return { success: false, state: this.lifecycleState };
if (!token) {
console.warn('[Gmail Observer Lifecycle] Degraded: Token acquisition/refresh failed.');
this.scheduleBootRetry('TOKEN_REFRESH_FAILED');
@@ -338,6 +342,7 @@ export class GmailPoller {
}
stop() {
+ this.bootVersion++;
this.clearBootRetryTimer();
if (this.timer) {
clearInterval(this.timer);