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(webhook): make the retry daemon's tick safe against a throw

Sampath04119760b5efe001
diff --git a/apps/payment-api/src/index.js b/apps/payment-api/src/index.js
index 69f66d1..9b0eb92 100644
--- a/apps/payment-api/src/index.js
+++ b/apps/payment-api/src/index.js
@@ -285,8 +285,16 @@ export function createPaymentApp(customDb = null, options = {}) {
if (queueSyncDaemon.unref) queueSyncDaemon.unref();
// Continuous Recurring Webhook Retry Daemon (Sweeps and dispatches pending webhook deliveries every 5s)
+ //
+ // The tick is defensive: `retryPending()` is expected to return a promise,
+ // but a throw inside it — or a non-promise return — must not escape the
+ // interval callback, because an exception thrown from a timer callback is
+ // an unhandled error that can take the process down.
const webhookRetryDaemon = setInterval(() => {
- webhookEngine.retryPending().catch(() => {});
+ try {
+ const outcome = webhookEngine.retryPending();
+ if (outcome && typeof outcome.catch === 'function') outcome.catch(() => {});
+ } catch {}
}, Number(process.env.WEBHOOK_RETRY_INTERVAL_MS || 5000));
if (webhookRetryDaemon.unref) webhookRetryDaemon.unref();