Bug: Zoho duplicate-lead handler has broken async error handling #56

Closed
opened 2026-05-17 17:24:34 -05:00 by null · 0 comments
Owner

Problem

In server/index.js, the duplicate-lead catch block (around line 428) calls forwardToZoho(sanitized) inside a try/catch, but forwardToZoho is an async function. The try/catch will not catch async rejections — they'll become unhandled promise rejections instead.

Additionally, forwardToZoho is called without await in the happy path (line ~416), which is the intended fire-and-forget pattern. But the duplicate-lead branch wraps it in try/catch as if it were synchronous, creating a false sense of error handling.

Code

// Happy path — fire and forget (correct intent, but no .catch())
forwardToZoho(sanitized)

// Duplicate branch — broken error handling
try {
  forwardToZoho(sanitized)  // async, not awaited!
} catch (zohoErr) {
  log.warn(`[Zoho] Skipped forwarding for duplicate lead: ${sanitized.email}`)
}

Fix

  1. Remove the useless try/catch wrapper in the duplicate-lead branch
  2. Add .catch() handlers to both forwardToZoho calls to prevent unhandled rejections:
forwardToZoho(sanitized).catch(err => log.error('[Zoho] Forwarding error:', err.message))

Severity

Low — Zoho forwarding is currently disabled (ZOHO_ENABLED defaults to false), so this doesn't affect production. But it should be fixed before Zoho is enabled.

## Problem In `server/index.js`, the duplicate-lead catch block (around line 428) calls `forwardToZoho(sanitized)` inside a `try/catch`, but `forwardToZoho` is an **async** function. The `try/catch` will not catch async rejections — they'll become unhandled promise rejections instead. Additionally, `forwardToZoho` is called without `await` in the happy path (line ~416), which is the intended fire-and-forget pattern. But the duplicate-lead branch wraps it in `try/catch` as if it were synchronous, creating a false sense of error handling. ## Code ```js // Happy path — fire and forget (correct intent, but no .catch()) forwardToZoho(sanitized) // Duplicate branch — broken error handling try { forwardToZoho(sanitized) // async, not awaited! } catch (zohoErr) { log.warn(`[Zoho] Skipped forwarding for duplicate lead: ${sanitized.email}`) } ``` ## Fix 1. Remove the useless `try/catch` wrapper in the duplicate-lead branch 2. Add `.catch()` handlers to both `forwardToZoho` calls to prevent unhandled rejections: ```js forwardToZoho(sanitized).catch(err => log.error('[Zoho] Forwarding error:', err.message)) ``` ## Severity Low — Zoho forwarding is currently disabled (`ZOHO_ENABLED` defaults to `false`), so this doesn't affect production. But it should be fixed before Zoho is enabled.
null added the
P3 Low
bug
backend
labels 2026-05-17 17:30:44 -05:00
null closed this issue 2026-05-17 17:47:02 -05:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: null/Queue-North-Website#56
No description provided.